Could anybody please tell me why is the output of both the prints are not same? How to pass an array of strings to a function then?
main()
{
char b[10][10];
printf("%p, %p, %p\n", b, b[0], b[9]);
getStrListFromString(b);
}
void getStrListFromString(char **strList)
{
printf("%p, %p, %p\n", strList, strList[0], strList[9]);
}
Expected OUTPUT :
0x7fffbe4ecf00, 0x7fffbe4ecf00, 0x7fffbe4ecf5a
0x7fffbe4ecf00, 0x7fffbe4ecf00, 0x7fffbe4ecf5a
Actual Output :
0x7fffbe4ecf00, 0x7fffbe4ecf00, 0x7fffbe4ecf5a
0x7fffbe4ecf00, 0x7fffbe4ecf80, (nil)
void getStrListFromString(char strList[10][10])for the prototype. 2D arrays are not pointers on 1D arrays.%pmust be cast tovoid *.