Scanf and ordinary characters.
Hello to all. I have some particular questions about scanf and how its works.
Assuming that we have the code :
Code:
#include<stdio.h>
int main(void)
{
char mychar;
printf(" Give a character : ");
scanf("%c" , &mychar);
printf(" Your char is : %c" , mychar);
return 0;
}
Assuming that we have the INPUT :
Code:
Give a character: <- I pushed ENTER
Character is: <- What is here?
Well , ENTER character have been stored into mychar variable?
On the other hand if I have
Code:
scanf(" %c" , &mychar);
If I give ENTER ( '\n') + A (character) scanf will match ENTER with space ordinary into format string of scanf and then will match A with mychar variable (due to %c conversion specification ??)
Thank you in Advance
Mr. Lnx