📄 finput.h
字号:
#ifndef FINPUT_H
#define FINPUT_H
void Finput() //从文件读入文本
{
v.clear();
system("cls");
cout<<"请输入文件名,将打开以.lhs为后缀的文件:";
string temp;
cin>>temp;
temp=temp+".lhs";//添加后缀
fstream fin(temp.c_str(),ios::in);
if(!fin)
{
cout<<"文件打开失败或文件不存在!"<<endl;
system("pause");
}
else
{
fin>>LineNum;
fin.ignore();
for(int i=0;i<LineNum;i++)//将文件中的文本读入到内存中去
{
string str;
getline(fin,str);
Line * tp=new Line;
tp->length=str.size();
tp->s=str;
v.push_back(tp);
}
fin.close();
cout<<"文件"<<temp<<"打开成功!"<<endl;//打开成功提示
system("pause");
}
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -