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);
what is wrong with this code?
it's incomplete :-D
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?
o thanks for the site
that's strange.... nothing obviously wrong with the code up there :(
Thats what im saying..I am done looking at this code but it just don't seems to work for me
Try flushing the input buffer before the getline()
nice tip, how would I do that...
cin.ignore(); right above the getline
worth a try :-D
did it work?
your genius man!
IT JUST WORKED!
i was going crazzy with code for two days.
yeah C++ is strange sometimes :(
Join our real-time social learning platform and learn together with your friends!