我正在嘗試將一個.csv文件讀入C++算法中,並且我試圖將每列存儲在內置於結構中的不同字符串數組中。工作正常,直到棧溢出錯誤發生,任何人都可以知道錯誤在哪裏? 的#include 的#include 的#include 的#include當試圖將.csv數據複製到C++中的結構時,堆棧溢出錯誤
using namespace std;
struct burgerking //structure containing different strings for each column in .csv file
{
string longitude[7000];
string latitude[7000];
string location[7000];
string state[7000];
string address[7000];
};
void main() {
burgerking burger;
string line;
ifstream myfile;
myfile.open("burgerking.csv"); //opening the csv file
if(myfile.good())
cout<<"File is Good to be opened"<<endl;
int l=0;
int n=1;
int e=2;
int ss=3;
int j=0;
int b=0;
int kk=0;
int ll=0;
for(int i=0;i<40;i++)
{
getline(myfile,line,',');
if(i==0)
{
burger.longitude[j]=line;
j++;
l=l+7;
}
if(i==l)
{
burger.longitude[j]=line.substr(16,line.length());
j++;
l=l+7;
}
if(i==n)
{
burger.latitude[b]=line;
n=n+7;
b++;
}
if(e==i)
{
burger.location[kk]=line;
kk=kk+1;
e=e+7;
}
if(ss==i)
{
burger.state[ll]=line;
ss=ss+7;
ll++;
}
}
//myfile.close();
//myfile.open("burgerking.csv");
//for(int c=0;c<20;c++)
//{
// getline(myfile,line,',');
// if(c==3)
// {
// burger.address[0]=line;
// }
//}
for(int k=0;k<1;k++)// loop just to check the program output
{
cout<<burger.state[k]<<endl; //just to check the output
}
myfile.close();
system("PAUSE");
}
我猜35,000個字符串比棧可以處理更多。 –
那我該怎麼辦呢? – Murtaza