I tried to do some stuff with scanset in scanf but stuck somewhere.
when I write
char s1[250];
scanf("%[A-Z]",s1);
input : AHJHkiuy
Output: AHJH
and with this,
scanf("%[^\n]",s1);
input: abcd ABCD hie
output: abcd ABCD hie /*that is reading white space also (till \n) */
Now My question is, if I give input as:
ABCDahaj ahajABCD ajak12347ab
and want the output as:
ABCDahaj ahajABCD ajak
then how should the format string be written? That is, how should this scanset be used?
You could expand your example a little bit and achieve your goal.
scanf("%[A-Za-z ]", s1);
Another way to do this would be:
scanf("%[^0-9]", s1); /* Scans everything until a digit */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With