Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Conflicting Types error (http://www.go4expert.com/forums/conflicting-types-error-t5693/)

banafsh3h 6Aug2007 03:26

Conflicting Types error
 
i'm writing a simple program for my programming class and i can't get rid of this "conflicting types" error.

Code:

#include <stdio.h>
#include <stdlib.h>

main( )
{
  printf ("1 \n"); // 1
  printf ("2 \n"); // 2
  printf ("3 \n"); // 3
  printf ("4 \n"); // 4
  printf ("5 \n"); // 5
  f1 ( );
  printf ("6 \n"); // 6
  printf ("7 \n"); // 7
  printf ("8 \n"); // 8
}
void f1 (void)
{
    printf ("f1-9 \n"); // 9
    printf ("f1-10 \n"); // 10
    f2 ( );
    printf ("f1-11 \n"); // 11
    printf ("f1-12 \n"); // 12
}
    void f2 (void)
{
    printf ("f2-13 \n"); // 13
    printf ("f2-14 \n"); // 14
    printf ("f3-15 \n"); // 15

  system("PAUSE");       

}

the errors say: conflicting types for 'f1', conflicting types for 'f2'
what should i do?
:confused:

DaWei 6Aug2007 03:37

Re: Conflicting Types error
 
You haven't declared f1 () and f2 () BEFORE you use them. C will therefore presume that they accept an int and return an int. When you call them, you call them as accepting a void and returning a void. Either put the definitions ABOVE main, or put a declaration (prototype) above main.


All times are GMT +5.5. The time now is 05:03.