image
image

Go Back   macosx.com > Design, Media, Programming & Scripting > Software Programming & Web Scripting

Reply
 
Thread Tools
  #1  
Old May 1st, 2008, 03:37 PM
Registered User
 
Join Date: May 2008
Posts: 3
g4c9z is on a distinguished road
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
In XCode, this is presumably specified by creating an executable and editing its info, via Project -> Edit Active Executable "...".

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?
Reply With Quote
  #2  
Old May 3rd, 2008, 04:39 AM
Viro's Avatar
Registered User
 
Join Date: Nov 2003
Location: Oxford, UK
Posts: 2,452
Viro will become famous soon enoughViro will become famous soon enough
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.
Reply With Quote
  #3  
Old May 3rd, 2008, 09:08 AM
Registered User
 
Join Date: May 2008
Posts: 3
g4c9z is on a distinguished road
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.
Reply With Quote
  #4  
Old May 12th, 2008, 12:56 AM
Viro's Avatar
Registered User
 
Join Date: Nov 2003
Location: Oxford, UK
Posts: 2,452
Viro will become famous soon enoughViro will become famous soon enough
Hmm... don't really know the answer to this. Did you manage to find out?
Reply With Quote
  #5  
Old May 12th, 2008, 08:47 AM
Registered User
 
Join Date: May 2008
Posts: 3
g4c9z is on a distinguished road
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.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 12:19 AM.


Mac Support® Version 3.7.0 Beta 5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.