Traverse the string array in c -
#include <stdio.h> int main(int argc, const char *argv[]) { const char *s[] = {"a", "b", "c", null}; const char **p = s; while (*p != null) { printf("string = %s\n", *p); (*p)++; } homecoming 0; }
i want traverse string array , print string util come null sentinal. generate terminated signal sigsegv (address boundary error)message. can tell me why?
with line :
(*p)++ you increment p[0].
i guess not want.
replace :
p++; it should work fine ;)
c arrays string pointers
No comments:
Post a Comment