Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7565179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:05:15+00:00 2026-05-30T14:05:15+00:00

I have got this code that reads an integer using scanf and checks if

  • 0

I have got this code that reads an integer using scanf and checks if it is actually an integer by looking at the buffer.

int e_1; 
char c[1];
// noNeedToCleanBuffer is used to avoid buffer cleaning the first time.
int noNeedToCleanBuffer = 1;
do {
    // Clears the buffer.
    if (!noNeedToCleanBuffer)
        while ((c[0] = getchar()) != '\n') ;

    noNeedToCleanBuffer = 0;
    printf("Input an integer value: \n");
    e_1 = scanf("%d", &n);  

    c[0] = getchar();
} while ((e_1 != 1 && c[0] != 10) || (e_1 == 1 && c[0] != 10));

However I cannot figure out how to check if the input is between INT_MIN and INT_MAX (I get these from limits.h).

I was thinking of getting the number as a string and compare it with two strings that would represent INT_MIN and INT_MAX, but since I am using the standard c99 I am not allowed to use atoi() or itoa().

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:05:17+00:00Added an answer on May 30, 2026 at 2:05 pm

    If you really just want to check store it-

    1.)Store in long and then check

    2.)Store the number in string then convert the INT_MAX into a string by getting each digit and storing in string and then using strcmp()

    num = INT_MAX;
    i = 0;
    
    while(num != 0){
        str[i] = num % 10;
        num = num / 10;
        i++;
    }
    

    The number would be opposite in this string you can get it reversed quite easily by a simple loop

    Then use strcmp();

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a piece of code, that should countdown some number (in this
I have an Asp.net app that simply reads an xml file and this code
I've got code that I am using from another team and I have spent
I have got this code: XDocument xdoc = XDocument.Load(URI); XElement root = xdoc.Element(forecast); //get
I have got this code and I am trying to understand the convention followed,
I have got code like this var challegneListener; $(document).ready(function(){ var challegneListener = setInterval(challengeListenerBot(),5000); });
ok i got this problem. i have this routes: (code bit change) File:/home/dotcloud/current/config/routes.js exports.routes
I have got some javascript code and I'd like to convert this to C#.
Code is not running on .click when I have this: $(.cancel).click(function() { alert(got here);
I have got this error when using Enterprise Library 3.1 May 2007 version. We

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.