0

I need to redirect my C program output to a text file with the command line. I need a command that automatically puts a C program output to a text file, and a command that takes the input to a C program from a text file. Can someone help please?

Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126

1 Answers1

0

Basically, you need "input and output redirection".

Let's say you have a code that expects some output from user (you have fgets()in your code - just an example), you want program to read from file, instead of waiting for user input on cmd...

you would call it: program.exe < input.txt

Similarly, for output, you want printf() to write to file, instead of command prompt, you would do program.exe > output.txt

To combine both in one line program.exe < input.txt > output.txt

Rorschach
  • 694
  • 1
  • 7
  • 20