ProgrammingHard
printf("[%-6s|]", "ab"); What is printed?
- A. [abc |]
- B. [ab |]
- C. [ba |]
- D. [cd |]
Correct answer: B. [ab |]
The minus flag left-aligns the text in a field of six characters, so ab is followed by four spaces before the bar.
More C Programming questions
- printf("%+d %05.1f", 5, 3.14159); What is printed?
- char s[] = "abc"; printf("%c", s[strlen(s) - 1]); What is printed?
- char w[] = "ab"; printf("%zu %zu", sizeof w, strlen(w)); What is printed (on any platform)?
- char a = "cat"; char b[] = "cat"; printf("%d", strcmp(a, b) == 0); What is printed?
- char buf[3] = {'a', 'b', 'c'}; printf("%.2s", buf); What is printed?
- char s[10] = "xyz"; strcpy(s + 1, "ab"); printf("%s", s); What is printed?