creating a stream object with stdin

Hello all. I am stuck on a project I am working on, and need some help. I'm still kind of a beginner with C++, but it seemed like this topic wouldn't be good for the beginners forum.
I need to get some input from the stdin, but I don't know how to create a stream object and give it stdin. Any suggestions?
std::cin and std::wcin are the stream objects associated with stdin.

They already exist when the program starts up, there is no need to create them at run time, but if you must, std::istream mycin(std::cin.rdbuf());

What is this for?
It is a project for a class where we are learning to program in Unix/Linux. The goal is to simulate the process scheduler, using a few of the different algorithms like round robin, fcfs, ect. We get information about the processes from the user from stdin by either directing a file to stdin, or letting the user enter information. for example, at run-time I would enter this at the command line:
./project8 < in.txt
or else just use stdin to let the user enter the necessary info manually.

So, if I'm understanding correctly, I don't need to create a stream object at all, I can just say something like this:
1
2
3
4
while (!(EOF))
{
        cin >> array[index];
}


Yeah. By piping the text file in like that, cin will read from that file.
Or you could just do

1
2
while(cin >> array[index])
// ... 

If the input is a file, it will read until the end. If it's the console, it will read until a EOF (Ctrl-D).
Thanks guys, you were a huge help!
Topic archived. No new replies allowed.