Thread: Quick Header Question

  1. #1
    Registered User zdude's Avatar
    Join Date
    Sep 2002
    Posts
    32

    Quick Header Question

    What header files are the functions min (int, int) and max (int int) in?
    Those who live by the sword get shot by those who don't.

    I can C.

    Compiler: gcc

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    #include "mycustomhearder.h"

    Create your own functions.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    I don't know about gcc, but for borland compilers, they are in stdlib.h.

    Maybe someone else knows where they are for gcc.

  4. #4
    Open to suggestions Brighteyes's Avatar
    Join Date
    Mar 2003
    Posts
    204
    In C99, you can use the isgreater and isless macros defined in math.h. In C90 you're on your own:
    Code:
    int min(int a, int b)
    {
        return (a < b) ? a : b;
    }
    
    int max(int a, int b)
    {
        return (a > b) ? a : b;
    }
    p.s. What the alphabet would look like without q and r.

  5. #5
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    If you don't want to have to overload it for different datatypes, just use:
    Code:
    #define min( x, y ) ( x < y ? x : y )
    #define max( x, y ) ( x > y ? x : y )
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  6. #6
    Open to suggestions Brighteyes's Avatar
    Join Date
    Mar 2003
    Posts
    204
    >If you don't want to have to overload it for different datatypes
    You wouldn't be able to anyway. Overloading is illegal in C.
    p.s. What the alphabet would look like without q and r.

  7. #7
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Really?

    Shows how much I know about/use C. :P
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Header files question
    By Programmer_P in forum C++ Programming
    Replies: 8
    Last Post: 05-14-2009, 01:16 PM
  2. Precompiled header question
    By donglee in forum C++ Programming
    Replies: 13
    Last Post: 01-22-2009, 01:23 AM
  3. Quick question about types...
    By Elysia in forum C++ Programming
    Replies: 32
    Last Post: 12-07-2008, 05:39 AM
  4. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM