ProgrammingHard
printf("%.*s", 2, "hello"); What is printed?
- A. hel
- B. h
- C. hello
- D. he
Correct answer: D. he
The * precision takes its value from the argument list, so only two characters are printed.
More C Programming questions
- int n = snprintf(buf, sizeof buf, "%s", text); if (n >= (int)sizeof buf) puts("truncated"); What does the test detect?
- char src[] = "hey"; char dst[8]; memcpy(dst, src, strlen(src)); printf("%d", (int)strlen(dst)); What is the problem with this code?
- int arr[3] = {1, 2, 3}; int (pa)[3] = &arr; printf("%d", (pa)[2]); What is printed?
- int spiralcount = 4 5; printf("%d", spiralcount); For a 4 x 5 matrix, how many cells does a full spiral visit?
- A program climbs a staircase of 5 steps, each move going up one or two steps. How many distinct ways are there?
- The number of subsets of a 4-element set with an even number of elements is what?