c - First function call assigning a variable. Implicit declaration? -


consider,

    #include<stdio.h>     int main()     {     int y = facto(6);     printf("%d",y);     return 0;     }      int facto(int x)     {     if(x==1)       return 1;     else        return x*facto(x-1);     } 

i read in posts said calling function before defined implicit declaration. how statement overhere ("y = facto(6)"), implicit declaration ?

using gcc 4.8.1 on ubuntu 64 bit.

y=facto(6) implicit declaration because you're telling compiler "i want call function , pass single int, somewhere down road there function single int parameter."

if compiler ran int facto(int x) first, that's explicit declaration.

implicit declarations dangerous because compiler won't "hey, doesn't match i've found function."


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -