Redirection in Visual studio
-
I have a console C++ application that reads standard input and writes standard output. I want to run (i.e., debug) the program under the IDE, using a text file that I want to redirect to the program, and want the output to redirect to (over)write a text file. Going to the project properties, and under "Comand Arguments" typing "out.txt" (without the quotes) does not work. Neither does "<..\in.txt >..\out.txt" What am I doing wrong? Thanks! Tom
-
I have a console C++ application that reads standard input and writes standard output. I want to run (i.e., debug) the program under the IDE, using a text file that I want to redirect to the program, and want the output to redirect to (over)write a text file. Going to the project properties, and under "Comand Arguments" typing "out.txt" (without the quotes) does not work. Neither does "<..\in.txt >..\out.txt" What am I doing wrong? Thanks! Tom
Do you have something similar to the following in your code:
fread(..., stdin);
fwrite(..., stdout);If so, can you implement something like this instead:
FILE *in;
FILE *out;if (argc == 1)
{
in = stdin;
out = stdout;
}
else
{
in = fopen(argv[1], "r");
out = fopen(argv[2], "w");
}fread(..., in);
fwrite(..., out);"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
Do you have something similar to the following in your code:
fread(..., stdin);
fwrite(..., stdout);If so, can you implement something like this instead:
FILE *in;
FILE *out;if (argc == 1)
{
in = stdin;
out = stdout;
}
else
{
in = fopen(argv[1], "r");
out = fopen(argv[2], "w");
}fread(..., in);
fwrite(..., out);"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
Thanks, David, but that's not the problem. The program works from the command line, e.g.,
prog.exe <in.txt >out.txt
What I want to know is how do you set this up within Visual studio? I would have thought setting up the command arguments from within VS would do the trick--but I have not figured it out. Again, thanks, Tom
-
Thanks, David, but that's not the problem. The program works from the command line, e.g.,
prog.exe <in.txt >out.txt
What I want to know is how do you set this up within Visual studio? I would have thought setting up the command arguments from within VS would do the trick--but I have not figured it out. Again, thanks, Tom
hain wrote:
The program works from the command line, e.g., prog.exe out.txt What I want to know is how do you set this up within Visual studio?
Given this scenario, just add
out.txt
to the Program Arguments box in the project's settings."Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
hain wrote:
The program works from the command line, e.g., prog.exe out.txt What I want to know is how do you set this up within Visual studio?
Given this scenario, just add
out.txt
to the Program Arguments box in the project's settings."Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
Apparently the rendering of the code was not right in my last message. What I want to do (from within VS) is
prog.exe <in.txt >out.txt where < and > are the redirection symbols.
You can't do that within the IDE.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
You can't do that within the IDE.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch