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 7058215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:05:10+00:00 2026-05-28T04:05:10+00:00

http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/ Return Value On success, the function returns the converted integral number as an

  • 0

http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/

Return Value

On success, the function returns the converted integral number as an int value.
If no valid conversion could be performed, a zero value is returned.
If the correct value is out of the range of representable values, INT_MAX or INT_MIN is returned.

So how I differ between atoi("poop") and atoi("0") and atoi("0000000")

Yes I can loop and check for all zeroes in case I get 0 result, but isn’t there a better way?

Notice: I use ANSI C89

  • 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-28T04:05:11+00:00Added an answer on May 28, 2026 at 4:05 am

    That’s one of the reasons atoi is sometimes considered unsafe. Use strtol / strtoul instead. And if you have it use strtonum.

    The function atoi is more dangerous than you might think. The POSIX standard says:

    If the value cannot be represented, the behavior is undefined.

    The C99 standard says this also:

    7.20.1

    The functions atof, atoi, atol, and atoll need not affect the value of
    the integer expression errno on an error. If the value of the result
    cannot be represented, the behavior is undefined.

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

Sidebar

Related Questions

According to this documentation http://www.cplusplus.com/reference/clibrary/ctime/time/ for time(NULL) If the function could not retrieve the
According to this http://www.cplusplus.com/reference/clibrary/csignal/signal.html SIGINT is generally used/cause by the user. How do i
I overloaded the 6 signals listed on this site http://www.cplusplus.com/reference/clibrary/csignal/signal.html Then i ran my
So according to the link here: http://www.cplusplus.com/reference/algorithm/max_element/ , the max_element function is O(n), apparently
According to http://www.cplusplus.com/reference/clibrary/ctime/time_t/ time_t is the number of seconds since midnight 1/1/1970 UTC. So
http://www.cplusplus.com/reference/algorithm/for_each/ Unary function taking an element in the range as argument. This can either
According to http://www.cplusplus.com/reference/stl/deque/push_front/ x is Value to be copied to the new element. T
Lookign at: http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/ for string (%.Ns) precision. When I use sizeof or a #define
according to this site http://www.cplusplus.com/reference/std/functional/unary_function/ this code should work #include <iostream> #include <functional> using
Possible Duplicate: What are the differences between struct and class in C++ http://www.cplusplus.com/reference/std/typeinfo/type_info/ I

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.