1.sscanf和sprintf用法
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
char c[50] = "123";
int a;
sscanf(c, "%d", &a); // 不要忘记 “&”
int b = 567;
sprintf(c, "%d", b);
cout << a << endl << c;
return 0;
}
/*
sscanf将字符数组转换为数字,输入到数字变量中
sprintf将数字转换为字符数组,输出到字符数组变量中
*/
2.fsprintf和fsscanf---文件相关
按格式写入 fsprintf(s, “%s love %s.”, who, whom); //产生:“I love CSDN. ” 这字符串写到s中
转载自:柳婼