Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!tut.cis.ohio-state.edu!rutgers!rochester!pt.cs.cmu.edu!cadre!pitt!darth!apexepa!jcj From: jcj@apexepa.UUCP (John Juback) Newsgroups: comp.sys.mac.programmer Subject: Buffering in MPW stdio Message-ID: <340@apexepa.UUCP> Date: 29 Aug 88 20:47:07 GMT Organization: Apex Software Corp., Pittsburgh, Pa. Lines: 38 I'm porting some UNIX utilities to the Mac as MPW tools. Predictably, there are sections of code that look something like this: char buf[256]; printf("Prompt: "); gets(buf); Unfortunately, "buf" contains the prompt string as well as the user's response (unlike any UNIX or DOS implementation of stdio that I've seen). I figured that the following lines would properly change the buffering mode: setvbuf(stdin, NULL, _IONBF | _IOSYNC, 0); setvbuf(stdout, NULL, _IONBF | _IOSYNC, 0); That didn't work, so I tried an explicit "fflush" right before the "gets." That didn't work either. I suppose that a routine like the following would do the trick, char *prompt(q, a) char *q, *a; { printf(q); gets(a); #ifdef ghs return a + strlen(q); #else return a; } but it's annoying that MPW hasn't faithfully ported stdio, nonetheless. Has anyone figured out a way to make stdio behave properly? -- ____ "Omit needless words." /\ | ) \ / / \ | --- / - Strunk and White / \ | ____ / \ John C. Juback Apex Software Corporation {allegra,bellcore,cadre}!pitt!darth!apexepa!jcj Phone: (412) 681-4343