#include<vector>
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main() {
//ofstream input("output.txt");//会覆盖掉原来的txt
//ofstream input("output.txt",ios::app); //会继续在原来的txt中写内容
//if (!input.is_open()) {
// cout << "cannot access to the file" << endl;
// return -1;
//}
//input << "hey"; //往文件中输入hey
//input << "hey"<<endl; //往文件中输入hey以及回车
//input.close();
ifstream file("output.txt");
char temp = file.get();
cout << temp << endl; //获得文件的首字母 使用file.getline(file,content) 会往content中写入file的第一行
//这个会走光标
vector<string> names;
string msg;
while (file >> msg) {
names.push_back(msg);
}
cout << "read msging" << endl;
for (string name:names)
{
cout << name<<endl;
}
return 0;
}