Re: Problems piping input into program
From: muchan (muchan_at_promikra.si)
Date: 03/24/04
- Previous message: William Payne: "Problems piping input into program"
- In reply to: William Payne: "Problems piping input into program"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 24 Mar 2004 14:27:56 +0100
William Payne wrote:
> Hello, I am using Visual C++ 2003 and I can't seem to pipe input into my
> Win32 console program (written in C). Under Project->Properties I have added
> "< data.txt" (without the quotes) to Configuration
> Properties->Debugging->Command Arguments.
> The file data.txt is located in where my source files are. When I try to run
> the program, a dialog box says:
> Unable to start debugging.
> Unable to start program
> 'c:\coding\c\infixtopostfix_vc7.1\debug\infixtopostfix_vc7.1.exe
> Output cannot be redirected because the specified file is invalid.
>
> If I remove "< data.txt" the program starts, but then I don't get the
> desired input.
>
> I can, however, start from the command line when piping input.
>
> What am I doing wrong?
>
> / WP
>
>
Properties->Debugging->Command Arguments sets the argument, so that you
get the strings as args list in main() function, or as the lpCmdLine
parameter in WinMain() function. What program use the argument list
string is up to responsibility of the programmer, so if you don't do
anything with that, your program doesn't do anything redirecting
the file to stdin.
I think redirect with '<' is treated by command line shell, so,
you should first write interactive program with stdin as input,
debug it interactively, then test it with redirct from coonsole window.
(you can debug it by putting debug strings to stdout,
the way all the programmer were debugging in good old days..)
muchan
- Previous message: William Payne: "Problems piping input into program"
- In reply to: William Payne: "Problems piping input into program"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|