-   Programming (
-   -   error function in c code (

shams 08-05-2004 08:59 PM

error function in c code
this is a function code:
#include <stdio.h>
float x=4.5;
float y, float f(float);

printf(" %f %f\n",x,y);

float f(float a)

and this is the compilation error:
[root@localhost lbin]# gcc -o s104g s104g.c
s104g.c: In function `main':
s104g.c:5: error: parse error before "float"
s104g.c: At top level:
s104g.c:13: warning: type mismatch with previous implicit declaration
s104g.c:8: warning: previous implicit declaration of `f'
s104g.c:13: warning: `f' was previously implicitly declared to return
plz point me where is the mistake.

itsme86 08-05-2004 09:07 PM

Your mistake is right here:

float y, float f(float);
You can't define functions like that. Try moving float f(float); to somewhere above main (on a line by itself) and changing that original line to just float y;

Also, you should add return 0; to the end of your main function.

Nerox 08-06-2004 02:34 AM

Hi, try to compile float y, f(float); instead of float y, float f(float);

Kumar 08-06-2004 04:00 AM

please use code tags to post your code.

All times are GMT -5. The time now is 01:19 AM.