txt文件中所有信息讀取到char型數組中

# include <iostream>
# include <fstream>
# include <ios>
using namespace std;
int main()
{
    ifstream in("y.cpp");
    in.seekg(0, ios::end);
    int length = in.tellg();
    in.seekg(0, ios::beg);
    char * buffer = new char[length];
    in.read(buffer, length);
    in.close();
    cout.write(buffer, length);
    delete [] buffer;
    return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章