Created
April 13, 2023 09:22
-
-
Save muaddib1971/5712fc118a3b5a8b274ab9c6d558b72f to your computer and use it in GitHub Desktop.
cintest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <limits> | |
int main(void) { | |
int count{}; | |
while(true) { | |
std::string s; | |
std::cout << "ctrl-d has been pressed " << count << " times " | |
<< std::endl; | |
std::getline(std::cin, s); | |
if(std::cin.eof()){ | |
++count; | |
std::cin.clear(); | |
std::cout << std::numeric_limits<std::streamsize>::max() << "\n"; | |
std::cin.ignore(std::numeric_limits<std::streamsize>::max()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment