Is it correct to use scanf() as follows:
int n;
scanf("[%d]", &n);
If so, what does it do?
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.
It reads a square bracket (the
[), then a converts a decimal integer and stores the result inn, then reads a closing square bracket. The brackets themselves are simply skipped over, they’re not part of the conversion.You might be thinking of the character group conversion specifier, which looks like
%[...], where the ellipsis should be replaced by characters to accept. See the manual page for details.