Scanset behaviour in scanf in C

前端 未结 2 1514
青春惊慌失措
青春惊慌失措 2021-02-04 18:40

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
         


        
2条回答
  •  别那么骄傲
    2021-02-04 19:19

    You could expand your example a little bit and achieve your goal.

    scanf("%[A-Za-z ]", s1);
    

提交回复
热议问题