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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:18:11+00:00 2026-05-13T15:18:11+00:00

The program saves a settings file as text which contains floating point numbers of

  • 0

The program saves a settings file as text which contains floating point numbers of type long double. The settings file can only be saved via the GUI (GTK2), while files can also be loaded via the command line and without bringing up the GUI.

Unfortunately, a user reports that in the files he has saved, due to his locale setting, the numbers are formatted with commas and the program refuses to load them (emitting error messages) from the command line but seems to load them when the GUI is open.

I have already asked the following question: MPFR, printf, decimal places, locales, file i/o problem which suggested using setlocale(LC_ALL, "C") which I placed at the beginning of main. As this did not work, I placed it after calling gtk_init_check but again, it made no difference. (EDIT It did make a difference after I installed a few locales.)

I want the program to always use the same locale setting (or non-localized locale setting – “C”) for these data files it saves, but don’t want to mess up the GUI by doing so.

How?

  • 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-13T15:18:11+00:00Added an answer on May 13, 2026 at 3:18 pm

    Store the locale in use at the top of your load/save code:

    char* loc = setlocale(LC_NUMERIC, NULL);
    

    Then for every instance where you write numeric values to your file call:

    setlocale(LC_NUMERIC, "C");
    /* code here for read/write of numeric values:
    fprintf(fd, "aspect %0.20lf\n", img->aspect);
    */
    setlocale(LC_NUMERIC, loc);
    

    Should do the trick.

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

Sidebar

Related Questions

Hi my program saves some settings (mostly string) to a text file, to retrieve
In windows vista, how can i change the filed date modified, of any file(text/binary)
I am working on a program that loads and saves data from text files,
A program receives a list of Messages (base type). Each message in the list
I have a program I wrote that when it has an error, it saves
My current approach is to store date in .settings file and update it at
I would like to save the programs settings every time the user exits the
I want to save the objects I generated in a program. After restart the
What do I need to do to save an image my program has generated
Here's the purpose of my console program: Make a web request > Save results

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.