ProgrammingModerate
char *names[] = {"ab", "cde"}; printf("%zu", sizeof names / sizeof names[0]); What is printed?
- A. 5
- B. 3
- C. 2
- D. 1
Correct answer: C. 2
names is an array of two pointers, so the division gives 2, the number of elements.
More C Programming questions
- for (char c = 'a'; c <= 'e'; c += 2) putchar(c); What is printed?
- char cnt[26] = {0}; cnt['c' - 'a']++; printf("%d", (int)('c' - 'a')); What is printed?
- printf("%s", (char[]){'h', 'i', '0'}); What is printed?
- char a = "ab", b = "ab"; printf("%d", strcmp(a, b) == 0); What is printed?
- char buf[8] = "12345"; buf[strlen(buf) - 1] = '0'; printf("%s", buf); What is printed?
- char s[] = "abc"; printf("%c", s[sizeof s - 1]); What is printed?