Thread: Function help

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    19

    Function help

    So i made a simple function to get the absolute value of a float type number because the abs() function outputs integer numbers.

    When i compiled the program, an error message popped out.

    "Error: Conflicting types for 'absf'"
    Code:
    float absf(float x)
    {
    	if(x<0)
    	{
    		x=-x;
    	}
    	return x;
    }

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    If you don't have a prototype for the function, above main(), and absf() is listed in the code below main(), then C will use it's own default prototype for absf() - which would be wrong, in this case (it assumes an int parameter, and an int return).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 06-09-2009, 02:19 AM
  2. Replies: 2
    Last Post: 02-26-2009, 11:48 PM
  3. Print function: sending a function.. through a function?
    By scarlet00014 in forum C Programming
    Replies: 3
    Last Post: 11-05-2008, 05:03 PM
  4. Replies: 14
    Last Post: 03-02-2008, 01:27 PM
  5. Replies: 9
    Last Post: 01-02-2007, 04:22 PM