1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Conflicting Types error

Discussion in 'C' started by banafsh3h, Aug 5, 2007.

  1. banafsh3h

    banafsh3h New Member

    Joined:
    Aug 5, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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:
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    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.
     

Share This Page