I have to correct an existing C file which has a bunch of format specifiers compilation errors. Can anyone tell the correct format specifiers for the following cases:
u_char(*) [10]
(I tried %s, but didn't work)
char(*) [10]
(I tried %s and %c, but didn't work)
Thanks.
Both are pointers to arrays, so you can dereference them to become arrays, which decay to pointers-to-first-element:
char arr[10];
char (*pa)[10] = &arr;
printf("%s", *pa); // or &((*pa)[0])
To spell it out: the type of pa
is char(*)[10]
, and the type of *pa
is char[10]
, and the latter decays to a char*
of value &((*pa)[0])
(equal to &(arr[0])
).