Nov 15, 2012 at 3:19pm UTC
Here name, roll and cl are strings. when i use cin>> for all it dont take second input and when i use getline (cin,) for all it skip first input.
1 2 3 4 5 6 7 8
cout<<"\n\t\t\tEnter Name: " ;
cin>>name;
cout<<"\n\t\t\tEnter Roll No. " ;
cin>>roll;
cout<<"\n\t\t\tEnter Class: " ;
cin>cl;
cout<<"\n\t\t\tEnter number of subjects: " ;
cin>>subjects;
i will be very thankful if you help me.
Last edited on Nov 15, 2012 at 3:20pm UTC
Nov 15, 2012 at 3:30pm UTC
Hmmm i think ur problem can be solved by using cin.ignore. give it a try...
Nov 15, 2012 at 3:31pm UTC
getline will get the entire line, whitespaces included. You just need to flush your buffer before using it. That';s why it's skipping your first input.
Nov 15, 2012 at 3:31pm UTC
it ignore first input i think?
Nov 15, 2012 at 3:32pm UTC
@burhan
yar tu koi sahi HAL bta. chawlain marni bnd kr
Nov 15, 2012 at 5:00pm UTC
Yr yehi solution ha, sachi ma. -_-