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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:18:50+00:00 2026-06-14T17:18:50+00:00

I have a stupid bug in one of my c++ source for a project.

  • 0

I have a stupid bug in one of my c++ source for a project. I do in this part of the source I/O operations. I have a stupid bug where I print the fscanf read value. Below in this part :
Firstly, I don’t read the good value and when I print a float value, I get a decimal value with a comma ‘,’ instead of a point ‘.’ between the integer part and the floating part.

FILE* file3;
file3=fopen("test.dat","r");
float test1;
fscanf(file3," %f ",&test1);
printf("here %f\n",test1);
float test3 = 1.2345;
printf("here %f\n",test3);
fclose(file3);        

where test.dat file contains “1.1234” and I get at the execution :

here 1,000000
here 1,234500

So, I did a simple test C program compiled with g++ :

#include <stdio.h>
#include <stdlib.h>

int main()
{
  FILE* file3;
  float test3;
  file3=fopen("test.dat","r");
  fscanf(file3,"%f",&test3);
  printf("here %f\n",test3);
  fclose(file3);
}

and it gives :

here 1.123400

This is the first time I have a bug like this. Anyone could see what’s wrong ?

  • 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-14T17:18:50+00:00Added an answer on June 14, 2026 at 5:18 pm

    Is your C++ locale somehow set to use a European convention? They use commas where we use points and points for thousand’s separators.

    Have a look at settings of environment variables

    LANG
    LC_CTYPE
    LC_ALL

    try setting en_GB or en_US. Having established that it is a locale problem, next decide what behaviour makes sense. Is diplaying 1224,45 a bug at all? The user has locale set for a reason.

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

Sidebar

Related Questions

Possible stupid question: let's say I have two apps contained within one project. Can
Sorry this might be a very stupid question. But I did have bug with
Edit : do not read this i AM stupid :) i have classes animal
i have a (perhaps stupid) question: im using 2 threads, one is writing floats
Update: This does work, I was being stupid :( i have the following extension
I have a feeling this is a stupid question but I can't find the
I have a stupid question. I got this variable: var type:int; and this function:
I'm sure this is a stupid bug that I'm missing but I can't seem
I'm getting this strange intermitent bug in a MVC 3.0 project When I build
This question may seem stupid, but, so be it! I have a stupid problem

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.