user5339252
user5339252

Reputation:

How to run an input txt file through a C file to an output txt file in Command Prompt?

I am trying to run a test file through my C program, but I seem to be making a mistake.

My program is stdin/stdout, so it should work. When I run it in the normal "Build and Run" popup of Code Blocks, by copying the file contents in, it runs perfectly fine. But when I run it in command prompt like

input.txt < maze.c > output.txt

it isn't working. I put all three files on the desktop as well, and used cd Desktop to get there. When I run that line, it opens the input file, and leaves the output file empty.

Any suggestions?

Upvotes: 2

Views: 3261

Answers (1)

Bromind
Bromind

Reputation: 1128

The command should be :

$ prog_name < input_file > output_file

not :

$ input_file < prog_name > output_file

Also, maze.c is the source code, not the compiled program.

Upvotes: 2

Related Questions