Suppose,\"5181 2710 9900 0012\"- is a string of digits.I need to take one single digit at a time as input from the string of number without space to make arithmatic operations .
Since scanf is the inverse of printf, you could verify this by printing any number with the modifier (just a little tip).*
In general, the number before the format is a 'width' modifier. In this case it means you're only reading one byte into a number. If you specify %d, it may be a number of arbitrary length.
Example:
#include <stdio.h>
int main() {
int a;
sscanf("1234", "%d", &a);
printf("%d\n", a); // prints 1234
sscanf("1234", "%1d", &a);
printf("%d\n"m a); // prints 1
}
%d
format, though, since that would change the meaning of the number. However, for many cases you could try what printf
would do to predict scanf
's behavior. But of course, reading the manual or docs on it is always the more helpful approach :)