c++的问题 关于文件打开 读取数据 高分!!!

来源:百度知道 编辑:UC知道 时间:2024/05/17 20:32:40
我要打开一个“data.txt”的文件 里面的内容是:
“0 1 2 2 3 3 4 4 和
100 277 300 100 100 277 27 199 399”两组数据
我想把他们分别赋值给两个二维数组
xy[1000][2] 和
ijk[20][2]
请问用什么办法好?
我用的是2005的编译软件 怎么用iftream fin ("data.txt) 并不能打开文件阿 同样的 我用6.0就可以 为什么啊????
carloshs 能说得详细点么
我用全路径"d:\\data.txt" 还是不可以阿
按行读取 怎么读取阿? 能帮我写出来么? 我是新手 谢谢~!!

iftream 要全路径。谢谢!按行读取并找寻空格就能实现你的功能。
ifstream::ifstream
ifstream();

ifstream( const char* szName, int nMode = ios::in, int nProt = filebuf::openprot );

ifstream( filedesc fd );

ifstream( filedesc fd, char* pch, int nLength );

Parameters

szName

The name of the file to be opened during construction.

nMode

An integer that contains mode bits defined as ios enumerators that can be combined with the bitwise OR ( | ) operator. The nMode parameter must have one of the following values:

ios::in The file is opened for input (default).

ios::nocreate If the file does not already exist, the function fails.

ios::binary Opens the file in binary mode (the default is text mode).
Note that the ios::nocreate flag is necessary if you intend to test for the file’s existence (the usual case).

nProt

The file protection specification; defaults to