Just need an example on how to use INT_MIN and INT_MAX

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • td0g03
    New Member
    • Jan 2007
    • 64

    Just need an example on how to use INT_MIN and INT_MAX

    I just need a example on how to use them. I know you have to #include <limits.h>.
    I been trying to find online, but all they give me is a range. Thanks in advance.
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    Since INT_MAX and INT_MIN should be declared statically you can access it by doing Limits::INT_MAX . That is unless they are included in another thing that is not called Limits. It would be something like <SomethingName> ::Limits or you could just try the :: scope resolution operator to see if it recognizes it then.

    Comment

    • td0g03
      New Member
      • Jan 2007
      • 64

      #3
      Originally posted by RedSon
      Since INT_MAX and INT_MIN should be declared statically you can access it by doing Limits::INT_MAX . That is unless they are included in another thing that is not called Limits. It would be something like <SomethingName> ::Limits or you could just try the :: scope resolution operator to see if it recognizes it then.
      Sorry, I'm still sorta confused. Anyway you could do me in c++ code? Thanks in advance.

      Comment

      • td0g03
        New Member
        • Jan 2007
        • 64

        #4
        Let me try to explain a little more. I been trying to use it in a loop. Where it will scan all the numbers that come in and see which one is the highest. I tried things like if
        Code:
        	printf("Enter your numbers: <EOF> to stop[CTRL Z].\n");
        	scanRes = scanf("%d", &x);
        	while ( scanRes != EOF)
        	{
        	   sum += x;
                   if(x>=largest)
                    largest = x;
        no luck however.

        Comment

        Working...