0
我有帶數字的文件。從數組中的文件中放入數字
3
2 15 41
4 1 2 3 4
3 22 11 24
第一行顯示其他行如何存在(最大100)。 號在行不能含有超過50
在數字線需要被放入數組是這樣的:
line[lineNum][num]
我用C++新,我問要做到這一點最簡單的方式更多鈔票。我試過:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
int kiek;
string str[100][50];
string line;
int a = 0;
int b = 0;
ifstream failas("Duom1.txt");
if (failas.is_open())
{
while (failas)
{
if (a == 29)
{
a = 0;
b++;
}
getline(failas, str[a][b], ' ');
}
a++;
}
cout << str[0][0] << endl;
}
明顯的問題。如果你有一個數字文件,你爲什麼說'string str [100] [50]'? 'int str [100] [550]'似乎是更好的事情。 – john