ilug-cal  

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

Sayamindu Dasgupta
Wed, 12 Feb 2003 09:49:34 -0800

On Wed, 2003-02-12 at 15:42, Manas Laha wrote:
> 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.
> 

..hehe same mistake that I made with my 1st C prog. ;-)
gcc -Wall solves it

    [unmadindu@localhost unmadindu]$ gcc -Wall -o ghu test.c
    test.c: In function `main':
    test.c:8: warning: format argument is not a pointer (arg 2)
    test.c:11: warning: control reaches end of non-void function
    [unmadindu@localhost unmadindu]$
    
Also, put a return(0) at the end of the src.
-sdg-
    



-- 
Sayamindu Dasgupta [ http://www.peacefulaction.org/sayamindu/ ]

=========================================
Speak out on social and cultural issues
                at
        PeacefulAction.Org
    http://www.peacefulaction.org
*****************************************


A black cat crossing your path signifies that the animal is going
somewhere.
                -- Groucho Marx


--
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