【发布时间】:2013-02-11 21:02:54
【问题描述】:
我的文本文件包含整数,例如:123 879709789 43536 8768768
我想读取一个数组索引中的整数,例如数组 [1]=123 数组 [2]=879709789。
这是我尝试过的:
ifstream myfile("numbers.txt");
if (myfile.is_open())
{
while ( myfile.good() && !myfile.eof() )
{
for(i=1; i<myfile.eof(); i++)
{
myfile >> ar[i];
if(ar[i]=="")
{
i++;
}
}
}
}
【问题讨论】:
-
想展示你的尝试吗?
-
您自己尝试过吗?从您现在的问题来看,我们看不到您有任何努力以某种方式自行解决。
-
ifstream myfile ("numbers.txt"); if (myfile.is_open()){ while ( myfile.good() && myfile.eof() ){ for(i=1; i
> ar[i]; if(ar[]==""){ i++; }