" conflicting types " error!!

Discussion in 'C' started by hamidr, Oct 28, 2006.

  1. hamidr

    hamidr New Member

    Joined:
    Oct 28, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    when i compile a simple program in Dev C++ i get error:" conflicting types for 'myf' "
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
      myf(3.0); 
      return 0;
    }
    
    double myf(double x)
    { 
      return x; 
    }
    what does that mean? :mad:
     
    Last edited by a moderator: Oct 29, 2006
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    You have posted it as an Article under the Article / Source code section. I have moved it to the Queries and Discussion forum.

    Use the code blocks for putting codes in the post

    I am not sure why there should be an error but I dont have the compiler so I could not solve it but try putting the function body above main and see if it solves the problem.
     
  3. Aztec

    Aztec New Member

    Joined:
    May 9, 2006
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    0
    Since you didn't provide the prototype of the function, so your compiler is assuming the type of function to be int but later finds a double as a type.

    To rectify it, provide the prototype of the function and stay happy.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice