non-blocking std::getline, exit if no input

后端 未结 3 1054
遇见更好的自我
遇见更好的自我 2021-01-11 11:51

Currently I have a program that reads from the standard input, occasionally the program needs to just keep running if no input is made, usually this is a test script there i

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-11 12:26

    You can use cin.peek to check if there is anything to read, and then call getline if there is. There's no such thing as non-blocking getline by itself though.

提交回复
热议问题