Robil som úlohu z 5. lekcie C++ ale diskusia k lekciám je značne mŕtva, tak to dám sem.
Zdroják:
#include <iostream> //1
//2
using namespace std; //3
int main() //4
{ //5
cout << "Zadaj pocet zamestnancov!\n"; //6
int pocet; //7
cin >> pocet; //8
cin.get(); //9
struct zamestnanci //10
{ //11
char meno[15]; //12
int vek; //13
char mesto[15]; //14
} osoba[32000]; //15
char pokr[2]; //16
int i; //17
for(i=0;i<pocet;i++) //18
{
cout << "\nZadaj meno " << i+1 << ". zamestnanca! (menej nez 15 znakov)\n"; //20
cin >> osoba[i].meno; //21
cout << "Zadaj jeho vek!\n"; //22
cin >> osoba[i].vek; //23
cout << "Zadaj jeho mesto! (menej nez 15 znakov)\n"; //24
cin >> osoba[i].mesto; //25
cout << "\nChcete pokracovat? A/N \n"; //26
cin.get(pokr, 1); //27
if(pokr == "n" || pokr == "N") //28
pocet = i; //29
}
cout << endl << endl << "\t\tZamestnanci" << endl; //31
for(i=0;i<pocet;i++) //32
{
cout << "Zamestnanec cislo " << i+1 << " - " << osoba[i].meno << endl; //34
cout << "Vek: " << osoba[i].vek << endl; //35
cout << "Mesto: " << osoba[i].mesto << endl << endl;
}
return 0;
}
Vždy po skompilovaní (0 errors) my to vyhodí chybu
Unhandled exception at 0x004125f7 in Projekt 5.exe: 0xC00000FD: Stack overflow.