#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>
#pragma warning (disable :4996)
//fscanf和fpritf函数的研究测试
//fscanf是格式化的行I/O输入,fscanf是格式化的行I/O输出
int main(){
char str[80];
float f;
FILE *pFile;
pFile = fopen ("myfile.txt", "w+");//创建一个名叫myfile.txt的文件,可读写
fprintf(pFile, "%f %s",3.6789, "sd");//文件输出
rewind(pFile);//恢复文件写入位置,将读写位置回到最开始
fscanf(pFile, "%f", &f);//向pfile中输入f的值
fscanf(pFile, "%s", str);//向平file中以字符串的形式输入str
fclose(pFile);//关闭流
printf("I have read: %f and %s \n", f, str);
system("pause");
return 0;
}
#include<stdlib.h>
#include<Windows.h>
#pragma warning (disable :4996)
//fscanf和fpritf函数的研究测试
//fscanf是格式化的行I/O输入,fscanf是格式化的行I/O输出
int main(){
char str[80];
float f;
FILE *pFile;
pFile = fopen ("myfile.txt", "w+");//创建一个名叫myfile.txt的文件,可读写
fprintf(pFile, "%f %s",3.6789, "sd");//文件输出
rewind(pFile);//恢复文件写入位置,将读写位置回到最开始
fscanf(pFile, "%f", &f);//向pfile中输入f的值
fscanf(pFile, "%s", str);//向平file中以字符串的形式输入str
fclose(pFile);//关闭流
printf("I have read: %f and %s \n", f, str);
system("pause");
return 0;
}