简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM