#include<QApplication>
#include<iostream>
#include<QString>
#include<QVector>
struct myStruc
{
int array[3000*2000];
};
int main(int argc,char* argv[])
{
QVector<myStruc> myVector;
myStruc currentStruc;
for (int i=0;i<5;i++)
{
currentStruc.name+="a";
currentStruc.array[0]=i;
myVector.push_back(currentStruc);
}
for(int i=0;i<5;i++)
{
std::cout<<myVector[i].name.toStdString()<<" "<<myVector[i].array[0]<<std::endl;
}
myVector.clear();
return app.exec();
}
#include<QApplication>
#include<iostream>
#include<QString>
#include<QVector>
struct myStruc
{
QString name;
int array[3000*2000];
};
int main(int argc,char* argv[])
{
QApplication app(argc,argv);
QVector<myStruc> myVector;
myStruc currentStruc;
for (int i=0;i<5;i++)
{
currentStruc.name+="a";
currentStruc.array[0]=i;
myVector.push_back(currentStruc);
}
for(int i=0;i<5;i++)
{
std::cout<<myVector[i].name.toStdString()<<" "<<myVector[i].array[0]<<std::endl;
}
myVector.clear();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Compile fine, got "segmentation fault" error when run it.
It works OK if I decrease array size to 3000, any solutions?
Thanks in advance.
Bookmarks