#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
void main()
{
char info[81];
string names[5];
double sales[5][5];
int count = 0;
int x = 0;
ifstream file;
file.open("sales.txt");
while(!file.eof())
{
x = 0;
file.getline(info, 80);
while(info[x] != (char)39)
{
while(info[x] != ' ')
{
names[count] += info[x];
x++;
}
x++;
for(int y = 0; y < 4; y++)
{
sales[count][atoi(&info[x])] = (atoi(&info[x + 1]) * 10) + atoi(&info[x+2]) + (.01 *((atoi(&info[x+4])*10) + atoi(&info[x+5])));
x += 7;
}
x++;
}
count++;
}
}
當我運行這個時出現運行時錯誤,但我無法弄清楚爲什麼。我不是很熟悉我的編譯器調試器,所以我在調試時遇到了麻煩。(while(info [x]!='')時出現訪問衝突錯誤)
什麼恐怖的代碼。你有一個非常好的理由,你爲什麼不能使用'std :: string'和'std :: getline'?沒有人可以真正想要調試*那混亂。 –
如果你說'(char)39',那麼你還應該說'x =(int)0',非? –