The < operator is the unix command for take the file on the right and put it in the program on the left.
This is homework so the instructor specifically asked that he be able to execute the program from the unix terminal with that specific call. The problem is argv will not include data_file in its array. For instance
Apparently this is more of a Unix question then a c++ question.
Say you have the program:
1 2 3 4 5 6 7 8
//Hello_World.cpp
#include <iostream.h>
usingnamespace std;
int main ()
{
cout << "Hello World";
}
Furthermore you have no other files in the directory except it's compiled version:
Hello_World
If you type:
Hello_World > Stuff
from the terminal you will create a file called Stuff. Inside that file will be
Hello World
Your terminal will look like this:
/home/
% Hello_World > Stuff
/home/
%
Notice that Hello World got print to the file Stuff not to the terminal. That is because the '>' changes standard output to the thing on the right. If you didn't include '>' on the command line and typed:
Hello_World
from the terminal then Stuff would not be created and your terminal would look like this:
Thanks for the help! I didn't know that '<' changed the standard stream when i first made this post. cin and cout are obviously in the std namespace so changing location of standard stream changes where cin and cout read/write. (which is what moorecm was getting at)
that made me realize what I was not understanding. In case you're still curious (Albatross) I'm using the solaris operating system and they have a unix terminal and it is tcsh.
He needs to use the < operator in the shell which begs the question what shell he's using.
His code will be independent of the shell. Redirection is redirection... It's equivalent to cat input_file | detect_cycle. The input is redirected to stdin. In fact, unless I'm mistaken, bash, sh, csh, tcsh, and zsh, all support it.