I found such an example of scanf in C book (this time not K&R):
scanf(" %[-' A-Za-z]s",&variable);
Can anybody provide me with information what does it accept?
I have not found any info about using ‘a’ or ‘z’ as conversion characters
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.
From the standard (C11, §7.19.6.2/12):
That means that your format expects a run of of the characters
-, space,A, …,Z,a, …,z.The
[conversion specifier has provisions for two special characters:%[^...inverts the matching set, and a hyphen (-) between two characters indicates a range, as is used in yourA-Zanda-z.