[net.micro.atari16] Bug in MEGAMAX C ?

bryan@ihnet.UUCP (b. k. delaney) (03/22/86)

I was over at a friends house who just got the MEGAMAX "C" 
compiler for his 520ST.  There seems to be a bug with the
printf function. For example:

#include <stdio.h>
main()
{
	int c;

	printf("Hello world\n");
	printf("Enter a Char:");
	c = getchar();
}

Does not Work  until you put a "\n" in the second
printf statement. 

				ihnet!bryan
p.s. We tried calling the program a.tos, but that did not help either

tim@ism780c.UUCP (Tim Smith) (03/26/86)

It sounds like stdout is buffered.  Try saying

	fflush( stdout );

before the getchar().
-- 

Tim Smith       sdcrdcf!ism780c!tim || ima!ism780!tim || ihnp4!cithep!tim

bammi@cwruecmp.UUCP (Jwahar R. Bammi) (03/26/86)

> 
> I was over at a friends house who just got the MEGAMAX "C" 
> compiler for his 520ST.  There seems to be a bug with the
> printf function. For example:
> 
> #include <stdio.h>
> main()
> {
> 	int c;
> 
> 	printf("Hello world\n");
> 	printf("Enter a Char:");
> 	c = getchar();
> }
> 
> Does not Work  until you put a "\n" in the second
> printf statement. 
That is not a bug. Printf write to stdout which is a bufferwed stream.
So if you want the prompt to appear before the getchar() you will have
to flush the stream something like

	printf("Enter a Char:");
	fflush(stdout);
	c = getchar();

	I tried it  just now, and it works.
-- 
					Jwahar R. Bammi
			       Usenet:  .....!decvax!cwruecmp!bammi
			        CSnet:  bammi@case
				 Arpa:  bammi%case@csnet-relay
			   CompuServe:  71515,155