So I\'m trying to get the C program to read a filename from the command line in the following format: cat (filename path) | (program name)
i can get it to read the n
Piping content into a process does not put the values into argv
; rather, it puts the values onto that process's stdin
.
You need to check if argc
is greater than 1. If it is, then argv[1]
has the filename you've been given (well, the first argument to the program, anyway). If not, you need to read from stdin
to get the filename.