Thanks, that fixed it, but I have another question. I'm trying to write a program that displays its command-line arguments in reverse and does not display the program name. I have wrote this:
1 2 3 4 5 6 7 8
#include <iostream>
#include <fstream>
usingnamespace std;
int main( int argc, char**argv) // returns 1 on error
{
for (int ctr = argc; ctr; ctr--)
cout << argv[ctr] << " ";
}
and included <iostream> just as you suggested.
I get no output and after I run ./test it just goes to the next line.
I'm using Ubuntu Linux and do: g++ <filename> -o test
followed by: ./test
to run the program, but unfortinately I get no output.
I tried to do: ./test <filename> abc xyz
but that does nothing. I have no idea what command-line arguments I'm supposed to type and what the syntax of them is. This is just a program that I got from the book and I'm learning C++, can you please help me with this