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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:37:22+00:00 2026-06-06T06:37:22+00:00

My problem is the following. I try to convert a string into double. In

  • 0

My problem is the following. I try to convert a string into double. In this way:

string str = "1.1";
double d = atof(str.c_str());

But this don’t work, it simply return 1;

But if I try:

string str = "1,1";
double d = atof(str.c_str());

it return 1.1.

That is really weird. Seems it can only understand the number if I write a “,” but return as a “.”.

Any idea how could I solve this to convert “1.1” as well?

  • 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-06-06T06:37:25+00:00Added an answer on June 6, 2026 at 6:37 am

    The function is locale aware, so it will parse the number according to your current locale settings.

    Since atof is part of C library, you have to use C library to change the settings. Check out clocale.

    Also have a look at C++ locale, which should be used if you use C++ features (string, istringstream) to parse the data. You can imbue the locale to the stream so that you don’t modify the global locale as in the case of C.

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

Sidebar

Related Questions

I try to convert a string into a date in t-sql. However get results
I'm having a problem with TRY...CATCH blocks. Can someone explain why the following code
I got a little problem. Sometimes, when I try to call the following code,
The problem is following: I want to automate the way my emacs starts. It
I have following problem, Code: String a=Yeahh, I have no a idea what's happening
Consider the following problem: A multi-line string $junk contains some lines which are encoded
Im facing following problem I have created mentioned condition, but when I choose y
I'm writing a Javascript <-> C# bridge and ran into the following problem: There's
I have the following script (it looks long, but well commented). Problem is, i
I'm trying to convert the following string 2012-04-13 04:08:42.794 to a date type: SimpleDateFormat

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.