fstream读写文件
来源:互联网 发布:世界省市区数据库 编辑:程序博客网 时间:2024/04/28 06:06
ifstream infile;
//打开文件
infile.open("input_assign01_01.dat");
if(!infile)
{
cout << "unable to open data file"<<endl;
return -1;
}
char str[255];
while(!infile.eof())
{
if(len ==1)
n = str[0] - '0';
else
{
x[i] = str[0]-'0';
y[i] = str[2]-'0';
cout << "Resident Location "<< i << ": (" << x[i] << "," << y[i] << ")" <<endl;
i++;
}
}
//打开文件
infile.open("input_assign01_01.dat");
if(!infile)
{
cout << "unable to open data file"<<endl;
return -1;
}
char str[255];
while(!infile.eof())
{
infile.getline(str,255); //此时str为char[]类型
//getline(infile,str); //此时str为string类型
int len = strlen(str);if(len ==1)
n = str[0] - '0';
else
{
x[i] = str[0]-'0';
y[i] = str[2]-'0';
cout << "Resident Location "<< i << ": (" << x[i] << "," << y[i] << ")" <<endl;
i++;
}
}
- 使用fstream读写文件
- fstream读写文件
- C++ fstream读写文件
- 读写文件(fstream)
- fstream文件读写
- C++fstream读写文件
- C++ fstream读写文件
- 文件读写 fstream
- C++ fstream读写文件
- fstream读写UNICODE文件
- C++利用fstream读写文件
- C++ fstream文件读写操作
- C++文件读写示例fstream
- C++文件读写(一):fstream
- fstream库的文件读写
- fstream读写文件注意问题
- C++ fstream文件流读写文件操作
- STL之文件读写类fstream
- 重温二维数组
- Windows常用运行命令集锦
- 熟记的知识点,更新中...
- Solaris+Oracle安装(详细图解)
- Centos 6.3安装Adobe Flash
- fstream读写文件
- 笛卡尔坐标系的旋转矩阵在OpenGL坐标系的应用
- Java 笔记
- setCharacterEncoding
- 关于MenuItem乱码问题
- 外公家的猫-八年级作文
- 为什么国外程序员爱用 Mac?
- 10进制和64进制互转
- jQuery UI库使用记录----accordion