开发者

How do I input data using the eclipse console? (c++)

I'm trying my hand at c++ and am using fedora eclipse (3.4.2) as my IDE.

At the moment I'm trying to enter a string of numbers into the console, get the program to sort them and spit them back out. The program is straight out of a book and works with xcode and through a normal terminal - so I know it's correct.

Basically I run the program and enter a few numbers into the eclipse console, the numbers are coloured green so I know its accepting the input correctly.

When I开发者_如何学C hit enter, the console jumps to a new line and nothing happens. When I press control+shift+D, nothing happens. When I press control+d, nothing happens.

I use eclipse for python too, and the console works properly. Just hitting enter inputs data to the program.

Am I missing something here? I've spent the last half hour or so trying to figure this out. Can anyone help me? Thanks.


What version of ecplise and what complier 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;
}


How does your program know that input has ended? It sounds like it accepts multiple lines of input in the console window. Isn't there some magic case that pops you out of that loop so you can process the input that's been collected? As other said, without the code there's no answer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜