C++文件操作

string  getFileContext(const string& filename)
{
    string str;
    str.clear();
    char buf[1024];
    char *p;
    p = buf;
    memset(buf, 0, 1024);
    ifstream in;
    in.open(filename);
    while ((*p = in.get()) != EOF)
    {
        p++;
    }
    cout << "Buf" << endl;
    puts(buf);
    str += buf;
    cout << str << endl;
    in.close();
    return str;
}
發佈了125 篇原創文章 · 獲贊 31 · 訪問量 21萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章