I've looked through some stuff to find out, but nothing proper has been found (or I am a bad searcher though).
Now I'm learning the scanf function from stdio.h header, and they say escape sequences are not recommended here because it 'confuses' the input, but what actually happens? I tested some code out and got results for differens ES:
#include <stdio.h>
int main(void)
{
int a, b, c;
printf("Enter values: \n");
scanf("%d%d%d\n", &a, &b, &c);
printf("The values are %d, %d and %d.\n", a, b, c);
}
Enter values:
1
2
3
randomstuff
The values are 1, 2 and 3.
The same is with '\t' sequence – it asks for one more value (I typed 'randomstuff') which is not stored anywhere. '\a' and '\b', on the other hand, behave differently and does not affect the input:
...
scanf("%d%d%d\a", &a, &b, &c);
printf("The values are %d, %d and %d.\n", a, b, c);
}
Enter values:
1
2
3
The values are 1, 2 and 3.
It becomes more confusing when I mess around with the position of the ES. '\n' and '\t' stop affecting the input:
...
scanf("%d\t%d\n%d", &a, &b, &c);
printf("The values are %d, %d and %d.\n", a, b, c);
}
Enter values:
1
2
3
The values are 1, 2 and 3.
whereas '\a' and '\b' start having some influence:
...
scanf("%d\b%d%d", &a, &b, &c);
printf("The values are %d, %d and %d.\n", a, b, c);
}
Enter values:
1
The values are 1, 0 and 32766.
Some say ES are not interpreted by scanf() and are simply taken as plain characters, but that does not seem true as well since it does interpret such ES like \' or \" in accordance with the rules.
So what is going on? PS and why is there 0 and 32766 in the last outcome?