ProgrammingVery hard
char s[10], w[10]; int n = 0; sscanf("abc123", "%[a-z]%d", s, &n); printf("%d", n); What is printed?
- A. 2
- B. abc
- C. 0
- D. 123
Correct answer: D. 123
The %[a-z] conversion reads 'abc' into s, and %d reads 123 into n. The printed value is 123.
More C Programming questions
- char s[] = "a b,c"; int count = 0; for (char t = strtok(s, " ,"); t; t = strtok(NULL, " ,")) count++; printf("%d", count); What is printed?
- char s[] = "abc"; char t[sizeof s]; strcpy(t, s); t[0] = 'X'; printf("%s%s", s, t); What is printed?
- printf("%zu", strlen("n")); What is printed?
- printf("%d", strlen("a0b")); What is printed?
- char s = "x"; char t[2] = {'y', '0'}; int r = strcmp(s, t); What does r look like?
- printf("[%03d]", 7); What is printed?