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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:44:37+00:00 2026-06-03T05:44:37+00:00

I am using libconfig to read/wirte config files in my C++ game. Right now

  • 0

I am using libconfig to read/wirte config files in my C++ game.

Right now I just have this one config file called video.cfg:

#Video config file
video:
{
    fps:
    {
      limited = true;
      value = 20;
    };
};

This config file handles the video settings of the game.

I am trying to write a very basic console program that modifies this values based on user input. However I have no idea how to do this. I can’t find anything in libconfig manual and nothing on Google.

So how do you edit values in Libconfig?

  • 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-03T05:44:39+00:00Added an answer on June 3, 2026 at 5:44 am
    #include <libconfig.h>
    
    int main() {
       config_t cfg;
       config_setting_t *vid_fps_lim = 0;
       config_setting_t *vid_fps_val = 0;
    
       config_init(&cfg);
    
       if (config_read_file(&cfg, "myconfig") == CONFIG_TRUE) {
    
          /* lookup the settings we want */
          vid_fps_lim = config_lookup(&cfg, "video.fps.limited");
          vid_fps_val = config_lookup(&cfg, "video.fps.value");
    
          /* print the current settings */
          printf("video.fps.limited = %i\n", config_setting_get_bool(vid_fps_lim));
          printf("video.fps.value = %i\n", config_setting_get_int(vid_fps_val));
    
          /* modify the settings */
          config_setting_set_bool(vid_fps_lim, 1);
          config_setting_set_int(vid_fps_val, 60);
    
          /* write the modified config back */
          config_write_file(&cfg, "myconfig");
       }
    
       config_destroy(&cfg);
    
       return 0;
    }
    

    I named the file “lcex.c” and the config file “myconfig” It builds and runs on my Debian Linux machine using the following…

    gcc `pkg-config --cflags libconfig` lcex.c -o lcex `pkg-config --libs libconfig`
    
    ./lcex
    

    Open your config file after running the app and you should see that the values have been updated.

    Disclaimer…error handling left out to make it easier to read. I didn’t build with -Wall, etc. As with any API, read the docs and handle potential errors.

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

Sidebar

Related Questions

using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();
Using Java,I have to fetch multiple sets of values from an XML file to
I am using CentOS 5. I have created an rpm spec file for a
I am using config.autoload_paths in a way very similar to this related question to
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
i am recording video from webcam using DirectshowLib2005.dll in C#.net..i have this code to
Using Flex 3, I would like to take an image snapshot such as this:
Using C# for ASP.NET and MOSS development, we often have to embed JavaScript into
I'm writing a multi-threaded server using boost::asio (for sockets), boost::thread (for threading), libconfig++ (for
In this new episode of the saga Me vs Boost, libconfig, protocol buffers and

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.