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

  • Home
  • SEARCH
  • 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 7667085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:00:34+00:00 2026-05-31T15:00:34+00:00

g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 #include <errno.h> … cin >> str; errno = 0 ;

  • 0

g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1

#include <errno.h>
...
cin >> str;
errno = 0 ;
double d = strtod(str.c_str(), NULL);
if (errno) {
    cout << "Please, enter number.";
}

on wrong input errno stay 0.

EDITED:
Next works fine:

char *err;
double d = strtod(str.c_str(), &err);
if (strlen(err)) {
    cout << "Please, enter number." << endl;
}
  • 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-31T15:00:35+00:00Added an answer on May 31, 2026 at 3:00 pm

    What kind of “wrong input”? According to the manpage, errno is only set when the input is a number that is too large or too small to be stored in the data type, but not when the input isn’t a number at all.

    If no conversion is performed, zero is returned and the value of nptr is stored in the location referenced by endptr.

    If the correct value would cause overflow, plus or minus HUGE_VAL, HUGE_VALF, or HUGE_VALL is returned (according to the sign and type of the return value), and ERANGE is stored in errno. If the correct value would cause underflow, zero is returned and ERANGE is stored in errno.

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

Sidebar

Related Questions

I am using PostgreSQL 9.1.3 (PostgreSQL 9.1.3 on x86_64-pc-linux-gnu, compiled by gcc-4.6.real (Ubuntu/Linaro 4.6.1-9ubuntu3)
gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 c89 Just wondering is there a better way to do
gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 Apache protable runtime 1.4 c89 and compiling in -m32 mode
g++ (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2 I have a static library called sdpAPI.a I am trying
Can anyone tell me if, when compiling a c++ program, does g++ (Ubuntu/Linaro 4.4.4-14ubuntu5)
g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5 I have the following static library called sdpAPI.a. I am
valgrind-3.6.0.SVN-Debian gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5 2.6.35-22-generic I am using valgrind to detect memory errors
Ubuntu has 8 run levels (0-6 and S), I want to add the run
ubuntu 9.04, fedora 11, redhat... what are the differences from a web server/development standpoint?
Ubuntu Server 9.10, Here is my file, test.py import commands blkid = commands.getoutput('blkid') print

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.