I am trying to input a line of data using getline(), but i have enter twice after each getline function. Any idea on it . Here is my source code below.
Name : husdarin merah
Nationality : indian
I/C number : 218946-32849263-6239
Address : central of india
Check your details .
Name : husdarin merah
Nationality : indian
I/C number : 218946-32849263-6239
Address : central of india
Why i need to enter twice after each input to proceed to the next input?
PLease Help me out ....
okie. but without the cin.ignore(1000,'\n') the output will be lik below.
Name : husdarin merah
Nationality : indian
I/C number : 1289563-3264
Address : central of india
Check your details .
Name : husdarin merah
Nationality :
I/C number : indian
Address : 1289563-3264
Press any key to continue
why become lik tis one ? the output is totally unmatch with wat i input. Then i still have to enter twice after the 1st getline();
I removed all those cin.ignore() lines and it worked fine for me.. set up exactly how you wanted it to.
Other than that problem.. i've found that you've written out of an array's bounds - plane s1[3];for(int i = 1; i <= 3; i++)
You're accessing s1[3] when it ends at 2.
When you get to 3 in your for() loop, your program will break.
To fix this error, change your for() loop - for(int i = 0; i < 3; i++) //access 0 first, then 1, then 2
Remember - array indexing starts at 0.
Fixed the probs. Act is not my source code prob. there is a bug on the getline for microsoft visual c++ 6.0 . So, anyone facing the same problem as me. Please kindly refer to this. http://www.edcc.edu/faculty/paul.bladek/getline_fix.htm