//sscanf用法小结
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
int main ()
{
char s[6] = "12345";
int b;
sscanf(s,"%d",&b);//把字符数组 s 中的字符转换成数字存到b中
cout << b;
system("pause");
}
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
int main ()
{
char buf[10];
sscanf("hello, world","%*s%s",buf); //%*s把hello忽略掉了。 注意:"hello,"后面要加空格
printf("%s\n", buf);
}
当然sscanf的用法远非如此,如果加上正则表达式就会更复杂