I am trying to write a student database. I've done most of it, however to improve im trying to write something that will display the infomation entered and then ask if this is correct, if it is then continue if not then start back at the entering data part.

here is an example of what ive got, its a long bit of code so i havnt included all of it, so it wont compile. Thanks.

cout<<"Enter name of student..."<<endl<<endl;
			getline (cin,pname,'.');
			cout<<"Enter student id number..."<<endl<<endl;
			cin>>pID;
			char choicecourse;

			student **store = new student*[nocourses];// I have a class called student made above

				for(int j=0;j<nocourses;j++)
				{
				string pcourse;
				string pgrade;
				int ppercentage;

				cout<<"Course "<<j+1<<", Is the student taking EM, Particle or C++ [E,P,C]?"<<endl;
				cin>>choicecourse;
				
					
					switch(choicecourse)
					{
					case 'E':
					case 'e':
					{
					pcourse="EM";
					cout<<"Enter the grade for the student taking EM..."<<endl;
					cin>>pgrade;
					cout<<"enter the percentage for the student taking EM..."<<endl;
					cin>>ppercentage;
					store[j] = new physstd(pname,pID,pcourse,pgrade,ppercentage);
					cout<<endl;
					//store[j]->print();
					physstd a(pname,pID,pcourse,pgrade,ppercentage);
					out<<a;
					}
		break;
					default:
					cout<<"Incorrect course"<<endl;
					break;
					
					}	
				}
			for(int j=0;j<nocourses;j++)
				{
				store[j]->print();
				delete store[j];
				store[j]=NULL;
				}  // Here i display the infomation the user has entered.  I would like then to ask if this is correct. if it is then break if not then go back to the beginning of the for loop 
			delete[] store;

obviously the remainder of the switch is below. Any help on this would be much appreciated. Thanks

Solved. A do{}while loop works.

Hey I have tried the same before seeing this. But its showing me error in the program. After trying much I got the output for it. But it was giving me wring out put. When I enter correct value or incorrect value it always accept that value. But after watching your code I got the right output.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.