char buf[512] = {0}; sscanf("123456 ", "%s", buf); printf("%s\n", buf); 结果为:123456 |
sscanf("123456 ", "%4s", buf); printf("%s\n", buf); 结果为:1234 |
sscanf("123456 abcdedf", "%[^ ]", buf); printf("%s\n", buf); 结果为:123456 |
sscanf("123456abcdedfBCDEF", "%[1-9a-z]", buf); printf("%s\n", buf); 结果为:123456abcdedf |
sscanf("123456abcdedfBCDEF", "%[^A-Z]", buf); printf("%s\n", buf); 结果为:123456abcdedf |
sscanf("iios/12DDWDFF@122", "%*[^/]/%[^@]", buf); printf("%s\n", buf); 结果为:12DDWDFF |
sscanf(“hello, world”, "%*s%s", buf); printf("%s\n", buf); 结果为:world %*s表示第一个匹配到的%s被过滤掉,即hello被过滤了 如果没有空格则结果为NULL。 |
通信人家园 (https://www.txrjy.com/) | Powered by C114 |