[comp.lang.c] Lightspeed "C" 3.02 Neophyte Question / prob.

pff@thumper.bellcore.com (Peter Ferris) (07/31/89)

Dear C & Mac Gurus,

I'm begining to teach myself "C" (AGAIN!).  I'm using LSC (Lightspeed C,
Version 3.02 by Symantec). Everything is going well BUT for one thing!  I've
"written" the following "Hello World" program - per K&R:

/*****
*
* Hello World - LSC 3.02
* Pete Ferris 07/15/89
*
*****/
#include <stdio.h>
main()
{
	printf("Hello world!\n");
}

Everything runs just fine... TOO fine!  I believe it works, but it's toooo
quick!  The console window opens, displays "Hello world!" and 'slams' shut
VERY, VERY quickly.  Any suggestions?  I've run this program on other Macs
and different versions of LSC with no probs.  Currently I'm running LSC 3.02, a
Mac IIX (8MB RAM). Any thoughts?  Many thanks!

Note: My project folder includes:

mactraps
hello.c
stdio
(not in any special order!)

Please e-mail replies to:

Pete Ferris
Internet: pff@thumper.bellcore.com
AppleLink: N1009

paul@steven.COM (paul) (08/03/89)

In article <1667@thumper.bellcore.com>, pff@thumper.bellcore.com (Peter Ferris) writes:
> Everything runs just fine... TOO fine!  I believe it works, but it's toooo
> quick!  The console window opens, displays "Hello world!" and 'slams' shut
> VERY, VERY quickly.  Any suggestions?  I've run this program on other Macs

I had this same problem on a 2 Meg Mac+ and had to put a scanf to accept
a carriage return.  getchar won't accept a straight carriage return.
It needs something to chew on.


.

ching@pepsi.amd.com (Mike Ching) (08/05/89)

In article <70@steven.COM> paul@steven.COM (paul) writes:
=In article <1667@thumper.bellcore.com>, pff@thumper.bellcore.com (Peter Ferris) writes:
=> Everything runs just fine... TOO fine!  I believe it works, but it's toooo
=> quick!  The console window opens, displays "Hello world!" and 'slams' shut
=> VERY, VERY quickly.  Any suggestions?  I've run this program on other Macs
=
=I had this same problem on a 2 Meg Mac+ and had to put a scanf to accept
=a carriage return.  getchar won't accept a straight carriage return.
=It needs something to chew on.

I usually use the unix_main routine when porting from the command line
environment. Rename your main routine to be _main and include unix_main.c
in your project. (It's 'unix main.c' with no underscore.) Programs will
then prompt for command line arguments and open a final dialog prompting
for a Return or click before exitting.

mike ching

siegel@endor.harvard.edu (Rich Siegel) (08/05/89)

In article <26616@amdcad.AMD.COM> ching@pepsi.AMD.COM (Mike Ching) writes:
>In article <70@steven.COM> paul@steven.COM (paul) writes:
>=> quick!  The console window opens, displays "Hello world!" and 'slams' shut
>=> VERY, VERY quickly.  Any suggestions?  I've run this program on other Macs

>in your project. (It's 'unix main.c' with no underscore.) Programs will
>then prompt for command line arguments and open a final dialog prompting
>for a Return or click before exitting.

	If you upgraded the compiler from 3.0 or 3.01 to 3.02, but you
DIDN'T upgrade the libraries, you'll have this problem; bringing the
libraries up to date should fix it. (The problem isn't related to the
presence or absence of unix main.c; any program that uses the console
should get a "Press return or close this window" message at termination.)

R.



~~~~~~~~~~~~~~~
 Rich Siegel
 Staff Software Developer
 Symantec Corporation, Language Products Group
 Internet: siegel@endor.harvard.edu
 UUCP: ..harvard!endor!siegel

"When it comes to my health, I think of my body as a temple - or at least
a moderately well-managed Presbyterian youth center." - Emo Phillips

~~~~~~~~~~~~~~~