|
#1
| |||
| |||
| XCode help - specifying the source of stdin I am trying to write a command-line application with XCode. My application takes input from stdin. The way I normally use it is to use redirection to specify the input file. For example: Code: program < input.txt But the dialog doesn't explain how to specify where input comes from. Changing the arguments to include "< input.txt" doesn't work, I guess because "<" is a symbol known to the Terminal, and XCode probably bypasses the Terminal. Changing the option to "Use Pipe for standard input/output" seems to have no effect - perhaps there's a way to specify a pipe, but the dialog won't let me. Searching the XCode User's Guide didn't explain it either - it mentions the "Use Pipe" option, but doesn't describe how it works. How can I get standard input from a file? |
|
#2
| ||||
| ||||
| Use the C function freopen. You should never bank on the terminal being present and C already has a standard function to do I/O redirection. See http://www.cplusplus.com/reference/c...o/freopen.html for an example of how to use this function. |
|
#3
| |||
| |||
| Thanks. Yeah, modifying my program is always an option, and is the workaround I've settled on. It would still be nice to know how the Xcode "pipe" option works though. |
|
#4
| ||||
| ||||
| Hmm... don't really know the answer to this. Did you manage to find out? |
|
#5
| |||
| |||
| No. I just modified my program to take the file as an argument instead of forcing it to be through standard input. It's not a big deal for me, but I imagine there are other people who can't or don't want to do that, and would like to find an answer to my question. |