I am using codeblock for c++ programming. I have an issue.
How I can stop this function in codeblock and return values
vector<double>vec;
double x;
while(cin>>x)
{
vec.push_back(x);
}
I tried Ctrl + c
but it stops entire run block
I am using codeblock for c++ programming. I have an issue.
How I can stop this function in codeblock and return values
vector<double>vec;
double x;
while(cin>>x)
{
vec.push_back(x);
}
I tried Ctrl + c
but it stops entire run block
Depending on the operating system you can stop the reading from standard input using either CTRL-Z (Windows OS) or CTRL-D (*nix like OS).
That will send a EOF character to cin
.
To use cin
afterwards for reading further input you need to call
cin.clear();
That will reset the eof
flag.
A side note: CTRL-C doesn't stop the compiler but the running executable from the terminal used.