Ask your own question, for FREE!
Mathematics 16 Online
OpenStudy (anonymous):

int main() { char answer; cout << "(A)ppend Records, (S)how Records, (E)xit " ; cin >> answer; switch(answer) { case 'S': readData(); break; case 'A': writeData(); default: break; } return 0; } //Write Data Function void writeData() { string fname,street,city,state,zipcode; char ans; ofstream myFile; myFile.open(FileName,ios::out | ios::app); //cout << "Append Records\n\n"; do { cout << "\nEnter Name:"; getline (cin,fname); cout << "Street: "; getline (cin,street); cout << "City: "; getline (cin,city);

OpenStudy (anonymous):

what is wrong with this code?

OpenStudy (anonymous):

it's incomplete :-D

OpenStudy (anonymous):

I know i just pasted the portion of it but my question is when I run the program it work correctly but when I select A to append the file it skip asking name and prompts at street?

OpenStudy (anonymous):

use a site like pastebin or http://ideone.com

OpenStudy (anonymous):

o thanks for the site

OpenStudy (anonymous):

that's strange.... nothing obviously wrong with the code up there :(

OpenStudy (anonymous):

Thats what im saying..I am done looking at this code but it just don't seems to work for me

OpenStudy (anonymous):

http://pastebin.com/eZzW8MAM

OpenStudy (anonymous):

Try flushing the input buffer before the getline()

OpenStudy (anonymous):

nice tip, how would I do that...

OpenStudy (anonymous):

cin.ignore(); right above the getline

OpenStudy (anonymous):

worth a try :-D

OpenStudy (anonymous):

did it work?

OpenStudy (anonymous):

your genius man!

OpenStudy (anonymous):

IT JUST WORKED!

OpenStudy (anonymous):

i was going crazzy with code for two days.

OpenStudy (anonymous):

yeah C++ is strange sometimes :(

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!