I typically acquire a character with %c, but I have seen code that used %*c%c. For example:
char a;
scanf("%*c%c", &a);
What is the difference?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In a
scanfformat string, after the%, the*character is the assignment-suppressing character.In your example, it eats the first character but does not store it.
For example, with:
If you enter:
xyz\n, (\nis the new line character) thenxwill be stored in objecta.With:
If you enter:
xyz\n,ywill be stored in objecta.C says specifies the
*forscanfthis way: