So, I'm doing a homework where we have to test our class. We were forbidden to use stl.:) The problem is that at the test_2 the program crashes. It works all until it gets beck to the main try statement. When it should jump to the exception it just crashes. Any idea why is this happening? Thanks in advance! :)
void test_2() //
{
int tomb[400];
for(unsigned int j=0;j<400;j++){
tomb[j]=j;
}
cout <<"array loaded \n";
Buffer<int> test2(40,"test2.txt","w");
Buffer<int> test21(40,"test21.txt","w"); // 40 meretu buffer
cout << "bufferek letrehozva \n";
for(unsigned int j=0;j<400;j++){
test2[j]=tomb[j];
}
cout << "buff loaded \n";
/* for(unsigned int j=0;j<400;j++){
cout << test2[j] << endl;
} */
test21=test2;
cout << "copy constr ran \n";
unsigned int i=0;
for(unsigned int j=0;j<400;j++){
if(i==39){for(i=0;i<40;i++){ //40 size buff
test21.printfile(test21[i]);}
i=0;}
else i++;
}
throw "gets here";
}
int main()
{
try
{
int number;
cin >> number; // nr of the test
switch (number)
{
case 1:
test_1(); // file_test
break;
case 2:
test_2(); // copyconst_test
break; // crashes here
case 3:
test_3();
break;
}
}
catch (exception& e)
{
cerr << e.what() << endl;
}
catch (int i)
{
cerr << i << endl;
}
catch (const char* s)
{
cerr << s << endl;
}
catch (...)
{
cerr << "*** Nagy baj van! ****" << endl;
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire