M
Martin M. Pedersen
Hi,
I have a program where I read a lot of user data. How can I handle
the case where the user press control-d ?
Is it possible to disable control-d or re-open the cin ?
I have made a small example which hopefully shows my problem.
Regards
Martin
#include <string>
#include <iostream>
int main()
{
std::string command;
while (true) {
getline(std::cin,command);
std::cout << std::cin.eof() << " " << command << std::endl;
}
}
===============================
tusk@skarbinika:~/programming/jiga/jiga/getinput$ ./getinput
hello world
0 hello world
1
1
1
[...continues, until I kill the program...]
I have a program where I read a lot of user data. How can I handle
the case where the user press control-d ?
Is it possible to disable control-d or re-open the cin ?
I have made a small example which hopefully shows my problem.
Regards
Martin
#include <string>
#include <iostream>
int main()
{
std::string command;
while (true) {
getline(std::cin,command);
std::cout << std::cin.eof() << " " << command << std::endl;
}
}
===============================
tusk@skarbinika:~/programming/jiga/jiga/getinput$ ./getinput
hello world
0 hello world
1
1
1
[...continues, until I kill the program...]