[comp.sys.mac.programmer] Using printf with MPW-C for output to terminal

bartels@haydn.kulesat.uucp (04/12/89)

I must implement a big package existing in C on a Vax to the Macintosh.
Now the biggest problem is that MPW-C doesn't support printf to the
console. I tried to define a global window and to redirect the output
(stdout (filedes = 1)) to the global window. You will see mine pogram
below. It just doesn't work.
A second way to solve the problem is to redefine the printf with
sprintf and drawtext but than I must control scrolling in the window,
.... Who knows waths the best solution?

#include <Types.h>
#include <Memory.h>
#include <Quickdraw.h>
#include <Palette.h>
#include <Fonts.h>
#include <Events.h>
#include <Menus.h>
#include <Windows.h>
#include <TextEdit.h>
#include <Dialogs.h>
#include <Desk.h>
#include <OSUtils.h>
#include <ToolUtils.h>
#include <SegLoad.h>
#include <stdio.h>
#include <ioctl.h>

typedef BitMap *BitMapPtr;

#define windowID			1000			/* Resource ID for main window */

main()
{
CWindowPtr ImagePort;
Rect Imagerect;
long int refCon;
CWindowRecord wRecord;
long arg;


InitGraf(&qd.thePort);
InitFonts();
InitWindows();
InitMenus();
TEInit();
InitDialogs(nil);
InitCursor();


SetRect(&Imagerect,40,40,350,350);
ImagePort = (CWindowPtr) NewCWindow((Ptr) &wRecord,&Imagerect,"\pMessagewindow",1,
                       documentProc, (WindowPtr) -1 ,0,refCon = 4);
arg = (long) ImagePort;
ioctl(1,TIOSPORT,&arg);
printf(" message");
while(! Button());
}
If you know a good solution please send me. Thanks for your attention,



					Yours sincerly,
								
									
					Rudi Bartels
					KU Leuven 
					Faculteit der Toegepaste Wetenschappen
					ESAT-MI2
					Kard. Mercierlaan 94
					3030 Heverlee
					Belgium
					email: bartels@kulesat.uucp
					Fax: 32-16-221855