How to enter data using the eclipse console? (C ++)

I tried my hand in C ++ and I use Fedora Eclipse (3.4.2) as my IDE.

At the moment, I'm trying to enter a string of numbers in the console so that the program sorts them and spits them out. The program is directly from the book and works with xcode and through a regular terminal, so I know that this is correct.

Basically, I run the program and enter a few numbers in the eclipse console, the numbers are green, so I know that it accepts the input correctly.

When I press enter, the console jumps to a new line and nothing happens. When I press Ctrl + shift + D, nothing happens. When I press the control button + d, nothing happens.

I also use eclipse for python and the console is working correctly. Just press enter data entry into the program.

Am I missing something? I spent the last half hour trying to figure it out. Can someone help me? Thanks.

+3
source share
2 answers

What version of ecplise and what are you using? The following worked for me on Eclipse Ganymede with GCC version 3.4.5:

#include <iostream>
using namespace std;

int main() {
    int x = 0;
    cout << "Type your input here:";
    cin >> x ;
    cout << "You entered " << x << endl;
    return 0;
}
+1
source

How does your program know that the login has ended? It looks like it takes a few lines of input in a console window. Isn't there some kind of magical case that pushes you out of this loop so that you can process the collected data? As another said, without a code there is no answer.

0
source

Source: https://habr.com/ru/post/1719240/


All Articles