What will be occurred in this lines of code :
char Message[10];
scanf("%s%*",&Message,'?');
Why it reads two lines and then it will igonre the second line ?
It gives me first line as output when i use
`printf("%s",Message)`
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.
See scanf reference: An asterisk prefix to a type (i.e. a “%*[type]” format string, where [type] is a scanf type specifier, e.g.
dors) means that the value read is to be ignored; so the ‘?’ parameter is actually just there as a “placeholder”, to indicate thatscanfwill read two values.The format string shown in the question (“%*”) is, however, invalid (it is missing the type specifier), meaning that the shown call will result in undefined behavior.