Say if I have a string like this
char foo[10] = "%r1%r2";
I want to take out the 1 and 2 and convert them into ints. How can I go about doing this?
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.
If you’re looking for a literal
%in the source string, you use%%to specify that in the format string (and inprintf(), you use%%in the format string to generate a%in the output); therrepresents itself.There are other ways to specify the conversion, such as
%*[^0-9]%d%*[^0-9]%d; that uses assignment suppression (the*) and a scanset ([^0-9], anything that’s not a digit). This information should be obtainable from the manual page forsscanf().