Scanset behaviour in scanf in C

前端 未结 2 1523
青春惊慌失措
青春惊慌失措 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:26

    Another way to do this would be:

    scanf("%[^0-9]", s1); /* Scans everything until a digit */
    

提交回复
热议问题