Write your question here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
void addstudent()
{
int c = 0;
c++;
system("clear");
cout << "A D D A S T U D E N T" << endl;
cout << "-------------------------------------" << endl;
cout << "Enter the course of the student: " << endl;
getline(cin,st[c].course);
cout << "Enter the roll no of the student: " << endl;
cin >> st[c].rno;
cout << "Enter the name of the student: " << endl;
getline(cin,st[c].name);
cout << "Enter the mobile no of the student: " << endl;
cin >> st[c].mobileno;
cout << "--------------------------------------" << endl;
}
|
The output is as follows:
A D D A S T U D E N T
-------------------------------------
Enter the course of the student:
Enter the roll no of the student:
343
Enter the name of the student:
Enter the mobile no of the student:
I can't enter the course or the name of the student. So, shortly i can't enter anything which is declared as string.
I can only enter integer values.
I know the other solution could be to use the char data type for entering the course and the name of the student. But i really want to work with a string as its easier and simpler.
Thanks.