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

  • Home
  • SEARCH
  • 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 578691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:17:15+00:00 2026-05-13T14:17:15+00:00

My program is reading a text file containing various lines of text for a

  • 0

My program is reading a text file containing various lines of text for a settings file. Some of the lines could get very large. Currently the buffer size is 4096 chars. It is possible that some lines could exceed this, whether through maliciousness or due to various factors operating within the program.

The current routines were rather tedious to write and now I want to expand the possible contents of the file which will require more of this tedious repetitive code. (This is for a settings type file, consisting of name value pairs and the occasional section header. Some numerical values need to be read as strings due to multiple precision).

The main thing I want is to read an arbitrary length line without buffer overflow. I’ve just discovered getline can do this for me, but, is there for heavens sake a library that will just do the whole lot of this tediousness for me?

edit:

I don’t wish to be forced to place an = sign between the name and values, a blank space should suffice as separator.

By widespread, I mean the library should be available in the standard packages of the popular Linux distributions.

I’m aware of libconfig but it seems complete overkill for my requirements.

  • 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-13T14:17:16+00:00Added an answer on May 13, 2026 at 2:17 pm

    My suggestion is, DIY, since it’s quite easy.

    • Read each line

    • count chars until your separator and after your separator

    • allocate buffers

    • and read name value pairs with sscanf

      like:

      sscanf(line, "%[^:]: %[^\n]", key, value);

    You will be safe since you counted chars before sccanf.

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

Sidebar

Related Questions

I have a Perl program that is reading html tags from a text file.
I have a VB.net program that I have reading a text file, what is
I'm tasked with reading a large text file (around 150 MB), parsing it and
I'm reading input in a C++ program. First some integers, then a string. When
I am reading a binary file into a parsing program. I will need to
Im trying to write a program to read a text file through args but
I'm having a problem where instead of reading a text file from the location
I am reading in a text file using FileInputStream that puts the file contents
Anyone got anything about reading a sequential number from text file per line and
The StreamReader locks a text file whilst it is reading it. Can I force

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.