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

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -