Wednesday, July 23, 2014

Difference between fun(void) and fun()



#include 
int main()
{
    static int i = 5;
    if (--i){
        printf("%d ", i);
        main(10);
    }
}
output:
4 3 2 1

#include 
int main(void)
{
    static int i = 5;
    if (--i){
        printf("%d ", i);
        main(10);
    }
}
output:
root@selvakumar-Lenovo-B460e:/C_pgms/DS# gcc test.c 
test.c: In function ‘main’:
test.c:7:9: error: too many arguments to function ‘main’
test.c:2:5: note: declared here

thanks to geeks for geeks

No comments:

Post a Comment