1. 常见用法。
charstr[512]={0};
sscanf("123456","%s",str);
printf("str=%s",str);
2. 取指定长度的字符串。如在下例中,取最大长度为4字节的字符串。
sscanf("123456","%4s",str);
printf("str=%s",str);
3. 取到指定字符为止的字符串。如在下例中,取遇到空格为止字符串。
sscanf("123456abcdedf","%[^]",str);
printf("str=%s",str);
4. 取仅包含指定字符集的字符串。如在下例中,取仅包含1到9和小写字母的字符串。
sscanf("123456abcdedfBCDEF","%[1-9a-z]",str);
printf......
阅读全文