Program is skipping over Getline() without taking user input [duplicate]

偶尔善良 提交于 2019-11-29 11:56:56

Cin is probably leaving the carriage return in the buffer which getline retrieves. Try

cin.ignore(1000, '\n');

cin.getline(Record[Entrynumber].Address,70);

The >> operator doesn't remove the newline character after retrieving data, but ignores leading whitespace before retrieving data, while getline just retrieves whatever is in there, and removes the '\n' after reading as it is apart of the line it is 'getting'.

Seeing as how there might be input left over in the buffer which your getline is reading first, I'd suggest you clear the buffer before trying to input the next data:

std::cin.ignore(std::numeric_limits<std::streamsize>::max(),'\n');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!