mercredi 25 mars 2015

CodeBlocks .exe has stopped working


Vote count:

0




my .exe well compiled program stops working after run it in CodeBlocks, It stops after typing cin>>f.name the to the console after the choosed choice I have a Windows 8 and i use GNU GCC compiler here is the code,maybe there is a code error , i don t know tanks for your attention :



using namespace std;
struct employee
{
string name;
int age;

};
employee employeeList[10];
class Stack
{
int pos;

public:
Stack(){};
void push(employee e)
{
employeeList[pos] = e;
pos++;

}
employee pop(int n)
{
if(n = pos - 1)return employeeList[pos];
if(n < pos - 1)
{
return employeeList[pos];
for(int j =n; j < pos; j++ )
{
employeeList[pos] = employeeList[pos + 1];
}

}
pos--;
}
string print(int n)
{
n = pos;
cout<<employeeList[pos].name<<endl;

}

char menu()
{

char choice;
cout << "Press 1. to push an employee"<<endl;
cout << "Press 2. to pop an employee"<<endl;
cout << "Press 3. to show an employee"<<endl;
cin>> choice;

return choice;


}


};

int main()
{
Stack s;
char input = s.menu();
int j;

do
{
switch(input)
{
case '1' :{employee f; cin>>f.name; s.push(f);}break;
case '2' :{int n; cin>>n; s.pop(n);} break;
case '3' :{int n; cin>>n; s.print(n);}break;
}
j++;
}
while(j < 10);


return 0;

}


asked 1 min ago







CodeBlocks .exe has stopped working

Aucun commentaire:

Enregistrer un commentaire