C - Why does this output "%s" -
char *x = "world"; x = &x[6]; printf("%s", x);
hi can't understand why above code outputting first argument in printf statement. if change printf("f%s",x);
outputs "ff%s" why output ff twice?
thanks
because reading beyond array boundary. array of length 6 (0-5) , you're accessing 6th member (your last available 5th). undefined operation , unpredictable things print out portion of printf statement.
Comments
Post a Comment