I am trying to pass a 2d array into a function but it keeps giving me errors. Can someone post some source of what the function will look like and how to call it.
Thanks
Cipr0
I am trying to pass a 2d array into a function but it keeps giving me errors. Can someone post some source of what the function will look like and how to call it.
Thanks
Cipr0
I do it like this. This example is with a 2D char array.
Cheers,Code:void fillArray( char (*aBuffer)[MAX_ROWS]){ int c =5; /* accessing individual elements. Should really ensure that i am not accesing elements passed max_rows here. e.g. if c<max_rows. But this is only example only */ strcpy(aBuffer[c], "Hello there"); /* filling with a for loop */ for(c=0;c<MAX_ROWS;c++) strcpy(aBuffer[c], "Some text"); etc... }
G'n'R
oh and you call it like this. sorry....
There are other ways to prototype the fillArray function. I think you can also do this. But no sure...Code:#define MAX_ROWS 1000 main(void){ char stringArray[50][MAX_ROWS]; fillArray(stringArray) etc... }
Code:void fillArray( char aBuffer[][MAX_ROWS]){ etc.... }
G'n'R