0

How would one read the following in C?

./a.out < /bin/ls

I would like to read the output of /bin/ls command in my program. But first I need to figure out how to get that output. Is there a way to do this?

Avocado
  • 93
  • 8

1 Answers1

1

You could use the piping feature, that:

connects the STDOUT (standard output) file descriptor of the first process to the STDIN (standard input) of the second.

Example:

/bin/ls | ./a.out
lucgerrits
  • 179
  • 7