标签:
#include <iostream> #include <fstream> #include <string> using namespace std; int main() { ifstream in; in.open("test.txt"); if(!in){ cout << "open file failed !"<< endl; return 1; } // char ch; // // get a char // while(in.read(&ch, 1)) { /// or replace with : in.get(ch) // cout << ch << endl; // } // get a line char chr[20]; while(in.getline(chr, 15)){ cout << chr <<endl; } in.close(); return 0; }
其他操作可参考:http://www.cnblogs.com/flatfoosie/archive/2010/12/22/1914055.html
标签:
原文地址:http://www.cnblogs.com/lifeinsmile/p/5285250.html