ProgrammingModerate
What is the value of sizeof("hello") in C?
- A. 5
- B. 7
- C. 1
- D. 6
Correct answer: D. 6
A string literal is an array of char one element longer than its visible text, because of the terminator.
More C Programming questions
- char buf[] = "abcn"; buf[strcspn(buf, "n")] = '0'; printf("%zu", strlen(buf)); What is printed?
- Why must the result of getchar() be stored in an int rather than a char?
- Which call reads a line into char buf[100] safely?
- char name[10]; / input: a long name / scanf("%9s", name); What is the most characters stored before the terminator?
- Records (name, score, age) are sorted by score descending, and by age ascending for equal scores. Input: (A,90,30), (B,90,25), (C,85,20)…
- qsort is used on an array of records where several records have equal keys. Which statement is guaranteed by the C standard?