ProgrammingModerate
char *s = "hi"; s++; printf("%s", s); What is printed?
- A. i
- B. hi
- C. h
- D. ih
Correct answer: A. i
s is a pointer to the string literal, and incrementing it moves to 'i' before the terminator.
More C Programming questions
- int x = 1; { int x = 2; printf("%d", x); } printf("%d", x); What is printed?
- printf("%d", (int)'A' + 'x01'); What is printed?
- for (char c = 'z'; c > 'w'; c--) putchar(c); What is printed?
- printf("%d", sizeof(void ) == sizeof(int )); What is printed?
- int a[3]; int p = a; printf("%d", p + 3 > a); What is printed?
- struct { int x; int y; } p = {.y = 2, .x = 1}; printf("%d", p.x + p.y); What is printed?