Are char **n and char n[][] equal or different? If equal or different why?
Are char **n and char n[][] equal or different? If equal or different why?
Originally Posted by ansi_1999Is a pointer to a pointer of type char:Code:char **n;
Is a two dimetional array of type char, if the second was written:Code:char n[][]
array 'n' would be an array in which each element contains 10 other elements.Code:char n[10][10];
I hope thats correct.
They're different. "char **n;" is a valid declaration of a pointer to a pointer called n. "char n[][]" is an illegal declaration. Even if it were correct: "char n[size][size];", the two would still be different. Arrays and pointers are not the same beast even though arrays will almost always decay into a pointer to the first element when you use them.Originally Posted by ansi_1999
only the first [] needs to be filled in ex(this is legal)Code:char n[][]" is an illegal declaration. Even if it were correct: "char n[size][size];",Code:char array[2][]={"blah","blah"};
You're turned around. Only the first dimension can be omitted, and then only if the declaration isn't a definition or the definition includes an initialization list so that the compiler might be able to determine the size without one explicitly being given. Your example is not legal, but these are.Originally Posted by linuxdude
Code:char array[][5]={"blah","blah"};Code:extern char array[][5];
I knew that. I wonder why I screwed that up. Thanx for the fix