LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   c program:Why this program is giving redeclaration error (http://www.linuxquestions.org/questions/programming-9/c-program-why-this-program-is-giving-redeclaration-error-4175440302/)

batman4 12-06-2012 11:13 AM

c program:Why this program is giving redeclaration error
 
Code:

main(){
display();
}
void display(){
printf("abc");
}


johnsfine 12-06-2012 11:38 AM

I don't know why the compiler lets you declare main() that way (without void or a return type). But I think your problem is that using display() before declaring it implicitly declares it. Then the later definition doesn't match that implicit declaration.

tronayne 12-06-2012 11:49 AM

Because you didn't
Code:

#include <stdio.h>

void        display        (void);

main()
{
display();
}
void display()
{
printf("abc\n");
}

Hope this helps some.

yahoosam 12-07-2012 12:58 AM

Try always "int" with 'main'
closing 'main' with "return 0;"


All times are GMT -5. The time now is 03:14 AM.