C++读取txt文件操作

#include <iostream>
#include <fstream>
using namespace std;
 
int main()
{
   
    ifstream in("code1.txt");
    char c;
    char a[1000];
    int n=0;
 
    while(in.get(c))
        a[n++] = c;
    cout<<a<<endl;
    return 0;
}

你可能感兴趣的:(C++读取txt文件操作)