ilug-cal  

Re: [ilug-cal] [OT]Problems with gcc

Manas Laha
Wed, 12 Feb 2003 02:15:58 -0800

Soumyadip Modak wrote:

> #include <stdio.h>
> 
> int main()
> {
>         float celsius, fahrenht;
> 
>         printf("Enter temp. in Celsius:");
>         scanf("%f",celsius);      <--- ERROR here!
          scanf( "%f", &celsius );  <--- Should be like this
>         fahrenht=(9*celsius/5)+32;
>         printf("Fahrenheit temp. is:%.3f",fahrenht);
> }
> 

I'm right now not on the machine that has the gcc3.2 compiler, but
compiling this program with gcc2.91 shows a syntax error in the line
that says "scanf .... ". Obviously, "celsius" should be "&celsius". I
wonder why the compiler on your machine didn't signal this error at
compile time. Naturally this will cause a "segmentation violation" error
at runtime. I must try this out with gcc3.2! This promises to be
interesting.

- Manas Laha

--
To unsubscribe, send mail to [EMAIL PROTECTED] with the body
"unsubscribe ilug-cal" and an empty subject line.
FAQ: http://www.ilug-cal.org/node.php?id=3