C++ question

Bananapie

New Member
I am coding C++ in Nano on PuTTy. When I program a program, my class normally has a program already made that we redirect our input too... so it gets it from the file that the class provides, rather than input from the actual keyboard. I am currently trying to do it from the keyboard, rather than using their file they provide... and it works, but it doesn't prompt me for what I need to enter.

We are working on the Sieve of Eratosthenes program, and I am supposed to enter an upper limit.

Code:
cout << "Enter the upper limit: " << endl;
cin >> upperLimit; //gets input for upper limit.
cout << endl << endl;


It should prompt me to Enter the upper limit right?

In fact, when I do go to execute it doing prog3.exe &> prog3.out, it just goes to the next line, and waits for me to enter something. I enter 25, and in the prog3.out file, it shows

Code:
Enter the upper limit:


The prime numbers:

  2  3  5  7  11  13  17  19  23

It works just fine, but just wondering why I don't get asked to enter the upper limit. I am relatively new to C++ coming from JAVA and just wondering why. :good:
 
Well it does "ask", it's just that all the output is being piped through to the output file. Try running the program without piping, and it should work fine.
 
Well it does "ask", it's just that all the output is being piped through to the output file. Try running the program without piping, and it should work fine.

It's been a while since I've messed with C++....but how are you coming to that conclusion? From what he posted, there is no evidence that he's outputting to a file. Unless you know something about the code he didn't post. In that case, I never said anything.
 
It's been a while since I've messed with C++....but how are you coming to that conclusion? From what he posted, there is no evidence that he's outputting to a file. Unless you know something about the code he didn't post. In that case, I never said anything.
Sure there is....
In fact, when I do go to execute it doing prog3.exe &> prog3.out, it just goes to the next line, and waits for me to enter something.
 
Well it does "ask", it's just that all the output is being piped through to the output file. Try running the program without piping, and it should work fine.

Yeah that is what I figured. So it just leaves to the assumption that you know what you are entering. Oh well, was just curious. Thanks :good:
 
Back
Top