Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I pass an array by parameter

Status
Not open for further replies.

mheilbut

Programmer
Apr 24, 2002
53
0
0
BR
I have an array:
array[4][4];

Then, I call a function:
FunctionInsert(column,array(?));

This function will get the column number I passed and assign the number 1 to all lines of the column.
I need to pass to the function the column number and the array that will be modified.

How do I do this... the way I am doing it brings me the following error:
"Invalid indirection".

Thanks in advance!

Michel, São Paulo, Brazil
 
I'm a bit unclear of what you're wanting but:

typedef
{
int Array[4][4];
} T_ARRAY; // For easier reference later

T_ARRAY array; // Declare the array as Array.Array[][]

then do the calling:
FunctionInsert(1, &array);

This does:
void FunctionInsert(int Column, T_ARRAY * TheArray)
{
// Now it's possible to access TheArray for read and write purpose
TheArray->Array[1][Column] = 1; // Set the value, use -> as it's a pointer value
if(TheArray->Array[0][Column] != 1) TheArray->Array[0][Column] = 3;
}

Totte
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top