السلام عليكم و رحمة الله و بركاته و كل عام و الجميع بألف خير
اخواني ارجو منكم المساعدة في حل عطل في هذا البرنامج انا لم اشاهد اي عطل لكن عند اقتران الـ display لا يطبع المعلومات المرادة بل يطبع معلومات عشوائية غير مفهومة
هل من احد يعرف لماذا
و شكرآ
هذا كود البرنامج
-----------------------------------------------------------------------------------
#include <iostream>#include<string>using namespace std;//------------- int top=-1; int size=2;int incree=-1;//---------------struct st{char name[30]; int id;float mark;};//end struct//--------------class mezo{st* in;public:mezo(){in=new st[2];}void Push(int ID,float Mark,char Name[10]){incree++;if(top>size-1){incre();}in[top].id=ID;in[top].mark=Mark;for (int i=0;i<=10;i++) {in[top].name=Name;}cout << in[top].name << " has been added \n\n";}//end push//-------------void Pop() { system("cls");if(top<0){ cout << "\n-->Stack Underflow\n\n" << endl; }else{cout << in[top].name << " been deleted \n";top--;}cout << "\n\n--> press any key to return ";system("pause");system("cls");}//end pop//------------bool Empty(){return top <0;}//end empty//------------void incre(){cout << " done Jump ^_^ ";system("pause");size*=2;st* newin = new st [size];for (int i=0;i<=top;i++){newin.id=in.id;newin.mark=in.mark;for (int j=0;j<=10;j++){newin.name[j]=in.name[j];}}delete [] in ;in = newin;}//------------void display(){system("cls");if(Empty())cout <<"--> Stack is Empty \n\n\n" ;else{ cout << " name mark id"<<" \n\n ";cout <<"-----|------|----\n";for ( int i=top;i>=0;i-- ){cout<<" ( " << in.name << ", " << in.mark << ", "<<in.id<<" ) \n";}cout << "\n\n--> press any key to return ";system("pause");system("cls");}}//end display//----------void clear(){system("cls");top=-1;cout << "\nAll data has been cleared \n\n"; cout << "\n\n--> press any key to return ";system("pause");system("cls");}};//end class//---------------- void main() {while(1){cout << " Choose one of the choices above (1-5) \n prees 1 to Add student \n press 2 to remove the last student \n press 3 to clear the data \n press 4 to display all information \n press 5 to exit \n ";int c;cin >>c;mezo s;int id;char name[10];float mark;switch(c){case 1:system("cls");top++;cout << "\n enter the name ["<<"]\n";cin>>name;cout << "\n enter the mark ["<<"]\n";cin >> mark;cout << "\n enter the id ["<<"]\n\n"; cin >>id;system("cls");s.Push(id,mark,name);break;case 2:s.Pop();break;case 3:s.clear();break;case 4:s.display();break;case 5: exit(0);default:system("cls");main();}//end while}//end switchsystem("pause");} //end main
-------------------------------------------------------------------------------