I'm trying to run a C program in a Unix environment and I have an input file as well. The teacher said we can run it by typing in
gcc programName ./a.out inputFile
gcc programName ./a.out inputFile > viewFile
int main(int argc, char* argv)
Your professor mentions two ways of calling the file:
./a.out inputFile > viewFile
For both forms:
argvwould be a string representing the program name,
POSIX shells interpret
> filename to mean redirecting the program's output (specifically stdout) to the given filename.
Command redirections do not appear in the list of arguments from the program's perspective (although there are usually system-specific ways of finding the original command line out).