ProgrammingVery hard
char buf[7] = "hello"; memmove(buf + 1, buf, 5); printf("%s", buf); What is printed?
- A. hhello
- B. hello
- C. hheel
- D. hhell
Correct answer: A. hhello
memmove behaves as if the five source bytes were copied first, so hello lands at positions 1 to 5. The terminator at index 6 is untouched, so the string is hhello.
More C Programming questions
- char s[] = "one two three"; int w = 0; for (char t = strtok(s, " "); t; t = strtok(NULL, " ")) w++; printf("%d", w); What is printed?
- int n = 0; sscanf(" 42 abc", " %d", &n); printf("%d", n); What is printed?
- char a[] = "Level"; int pal = 1; for (int i = 0, j = 4; i < j; i++, j--) if (a[i] != a[j]) pal = 0; printf("%d", pal); What is printed?
- char a[] = "Level"; int pal = 1; for (int i = 0, j = 4; i < j; i++, j--) if (tolower(a[i]) != tolower(a[j])) pal = 0; printf("%d", pal)…
- printf("[%-6s|]", "ab"); What is printed?
- printf("%+d %05.1f", 5, 3.14159); What is printed?