文件读取.txt
来自「学生毕业设计管理系统和图的有关操作」· 文本 代码 · 共 32 行
TXT
32 行
#include<fstream.h>
#include<iostream.h>
void main()
{
int i,n;
char name[100];
fstream f1;
f1.open("d:\\data.txt",ios::in);
cout<<"从文件中读取数据:"<<endl;
f1>>n;
cout<<n<<endl;
for(i=0;i<n;i++)
{
f1>>name;
cout<<name<<endl;
// i++;
}
f1.close();
}
数据文件
data.txt
5
计算机01-2
计算机01-3
计算机01-4
计算机02-5
计算机02-6
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?