Question 5
Back to Exercise
What is the output on a 64-bit system?
#include <stdio.h>
#include <string.h>
int main(void) {
const char *s = "const";
const char t[] = "const";
printf("%zu %zu %zu\n", sizeof s, sizeof t, strlen(s));
return 0;
}
- A 8 6 5 Correct
- B 6 6 5
- C 8 5 5
- D 5 6 5
Correct Answer: Option A
s is a pointer (8 bytes); t is an array holding the 5 letters plus '\0' (6 bytes). const does not change any size; strlen counts 5 characters.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!