something like this won't work, and the books that i have don't really go into the subject. any help would be appreciated. thanks in advance.Code:int funct(char *[][])
something like this won't work, and the books that i have don't really go into the subject. any help would be appreciated. thanks in advance.Code:int funct(char *[][])
by doing that you are actually passing through a 3d array. If you want to pass in a 2d do this:
where 100 is the size of the second dimension.Code:void foo( char p[][100] ) { // }
edit: the 100, could be any number and SHOULD be the size of YOUR array's second dimension
some entropy with that sink? entropysink.com
there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka
great! i thought i had seen something like that somewhere, but i just couldnt recall it. thanks again.
> could be any number and SHOULD be the size of YOUR array's second dimension
All minor dimensions MUST match.
There are 3 different ways of writing the same thing when it comes to passing multi-dimensional arrays to functions.
This is handy, because the first one permits a rather simple and dead easy to remember rule called "copy and paste"Code:/* all these are the same */ void foo( char p[50][100] ); /* size of 1st dim is entirely optional */ void foo( char p[][100] ); void foo( char (*p)[100] ); /* watch the (), char *p[100] is a different animal */
If you had
int arr[X][Y][Z];
You can simply copy and paste that into a function parameter
void foo ( int arr[X][Y][Z] );
And call it with
foo( arr );
Just like you would do for any non-array type really
If you want to go round chopping the X out of the function definition and declaration, then that is up to you. Though some lint tools will remark that the X size is redundant.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.