C Example: INI Config Parser: sections, key/value pairs and trimming
Writes an INI config to a temp file and parses it line by line: recognises [section] headers, splits each pair at the first =, trims surrounding whitespace, and prints entries grouped by section. Covers the usual edge cases: blank lines and comment lines are skipped.
🖥 Run OnlineGCC 10.2 · C11 standard · click ▶ to run · Copy code
🖨 Reference OutputMatches the online run in a standard C11 environment
parsed 4 entries [server] host = 127.0.0.1 port = 8080 [limits] max_conn = 128 timeout = 30
🧩 Keep Learning