0

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

Jonas
  • 6,915
  • 8
  • 35
  • 53
Rifet Gazdić
  • 83
  • 1
  • 2
  • 8

1 Answers1

1

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.