文件输入输出
谁能教我文件输入输出的方法
int a; FILE *in; //定义一个文件指针 in=fopen("test.txt","r"); //用fopen打开指定文件,并返回文件指针 fscanf(in,"%d",&a); //用fscanf进行读入,写出用fprintf
int a; fstream file("test.txt"); //打开文件 file>>a; //从文件读入a file<<a; //向文件写入a
#include<iostream> using namespace std; int main(){ freopen("in","文件名","r");//全局开启文件输入 freopen("out","文件名","w");//全局开启文件输出 ...... }