Scanset behaviour in scanf in C

Viewed 9398

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?

2 Answers
Related