Manas Laha
Wed, 12 Feb 2003 22:41:48 -0800
Sayamindu Dasgupta wrote:
>
> 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-
Quite right! Without the -Wall option to gcc you don't get the warning about the format arg not being a pointer. Using -Wall always is a good habit to grow. - 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