C commands in a Carbon window.
O.K., I'm learning C and am a bit bored of going into UNIX, typing out printf() and scanf() And seeing the results in green monotype. 
Is there a way - I do own the latest XCode - to set up an XCode project in C, but to direct all printf() and scanf() commands to a window?
In my old IDE : FutureBASIC, It could translate my
to an XCode project in C, and all that text would appear in a window. Oh, and it didn't look like there was any Quickdrawing either.
If anyone can help me - or, even better, point me towards a new XCode project template - please do so.
Thanks in advance.

Is there a way - I do own the latest XCode - to set up an XCode project in C, but to direct all printf() and scanf() commands to a window?
In my old IDE : FutureBASIC, It could translate my
Code:
PRINT 'HELLO WORLD'If anyone can help me - or, even better, point me towards a new XCode project template - please do so.
Thanks in advance.
~ Bring a Pen ~
The easiest way would be to redefine printf to call one of your own functions and have that output to a window. You can fclose(stdout) and reassign it to a FILE * you create yourself, but getting a FILE * to do what you want is fairly involved, though certainly possible. You could call pipe(), call fdopen() on the second file descriptor returned by it and assign that to stdout, then have a secondary thread blocking on read() on the other half of the pipe and outputting it to your window whenever it gets data. You might also be able to modify the _write function pointer in the FILE struct to point directly to a callback in your code, though I haven't tried this myself...
Also, if you have Xcode launch your application (only in debug mode? Can't remember), its output will go to a window in Xcode. Maybe that's good enough for your purposes?
Also, if you have Xcode launch your application (only in debug mode? Can't remember), its output will go to a window in Xcode. Maybe that's good enough for your purposes?
XCode's debug window works in debug or release modes. You can also type in it if you want to use getchar() or similar. I used it to develop a text adventure years ago when I first started hobby programming.
If you come to the stage of wanting to release something you night want to look into creating your own window/view system, or you could just use terminal.
If you come to the stage of wanting to release something you night want to look into creating your own window/view system, or you could just use terminal.
May I suggest that you try Lightweight IDE? The Console is not a full terminal emulation like the Terminal, but works for simple printf etc.
But if you want it to appear in a window of your own, part of your own program, you should use sprintf and append it to a text view.
But if you want it to appear in a window of your own, part of your own program, you should use sprintf and append it to a text view.
So, me being not much of a .xib or .nib fan,how would I 'append it to a text view'? Would I er, create a C proj in Xcode, then, er, link a , er, controller? 
Maybe there's a different way though, I've encased a UNIX exec. inside a .app bundle, so do I have to use Xcode? Could I just write a gcc C then encase it inside a simple (Applescript-generated) app? If I could do that, then I could make a GUI for that? IDE ideas...



Maybe there's a different way though, I've encased a UNIX exec. inside a .app bundle, so do I have to use Xcode? Could I just write a gcc C then encase it inside a simple (Applescript-generated) app? If I could do that, then I could make a GUI for that? IDE ideas...



~ Bring a Pen ~
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| No window focus in Carbon app on 10.5 | withnail | 3 | 3,429 |
Jan 9, 2008 02:25 PM Last Post: OneSadCookie |
|
| OpenGL and Carbon Controls in the same Window | Hasty | 1 | 2,680 |
Sep 1, 2006 10:19 PM Last Post: OneSadCookie |
|

