How does scanf() hold the output of printf from appearing on the screen? The loop must be iterating because i's value is increasing as shown by the output. To clarify, how does the loop iterate without displaying the output of printf?
Code:
char string[100] = {0};
char chr = 0;
int i = 0;
printf("Please enter the string you would like reversed:\n");
while (chr != '\n'&& i<99)
{
scanf("%c", &chr);
string[i] = chr;
printf("%d %c\n", i,chr);
i++;
}
Output:
Please enter the string you would like reversed:
This is a test
0 T
1 h
2 i
3 s
4
5 i
6 s
7
8 a
9
10 t
11 e
12 s
13 t
14
Your reversed string is:
tset a si sihT