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

The Archive Base Latest Questions

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

I am working on a c parser and wondering how expert manage large amount

  • 0

I am working on a c parser and wondering how expert manage large amount of text / string (> 100mb) to store in memory?
the content is expected to be accessible all the time in fast pace.
bg: redhat / gcc / libc

a single char array would be out of boundary causing segmentation fault…
any idea or experience is welcomed to share / discuss…

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

    mmap is the best way to deal with a large amount of data that is stored in a file, if you want random access to that data.

    mmap tells the virtual memory system to map a contiguous portion of address space to contain the data found in the file. The virtual memory system will allocate a range of address space, backed by that file. When you access any location in that address space, it will allocate a page of physical memory, read that section of the file in from the disk, and point that portion of your virtual address space to the physical memory that it used to read the file. When it needs to make more room in physical memory, it will write out any changes to disk (if applicable), and remove the mapping of that section of virtual address space.

    You would use it like so:

    #include <sys/types.h>
    #include <sys/stat.h>
    #include <sys/mman.h> /* the header where mmap is defined */
    #include <fcntl.h>
    
    int file;
    char *contents;
    struct stat statbuf;
    off_t len;
    
    file = open("path/to/file", O_RDONLY);
    if (file < 0)
      exit(1); /* or otherwise handle the error */
    
    if (fstat(file, &statbuf) < 0)
      exit(1);
    
    len = statbuf.st_size;
    
    contents = mmap(0, len, PROT_READ, MAP_SHARED, file, 0);
    if (contents == MAP_FAILED)
      exit(1);
    
    // Now you can use contents as a pointer to the contents of the file
    
    // When you're done, unmap and close the file.
    
    munmap(contents, len);
    close(file);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 274k
  • Answers 274k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When the decorator is called, it's called with a function… May 13, 2026 at 2:22 pm
  • Editorial Team
    Editorial Team added an answer Queue^% indicates a handle being passed by reference. However, the… May 13, 2026 at 2:22 pm
  • Editorial Team
    Editorial Team added an answer This causes some difficulty for me ofcourse, because now I… May 13, 2026 at 2:22 pm

Related Questions

I am working on a Reverse Engineering school project, which requires to translate manipulate
I am using a C# Application to call a Batch file which compiles and
I have been working on an open source project for awhile, http://gtkworkbook.sourceforge.net/ , and
I am writing a web server in C# and I'm trying to add support
I've recently started using the Areas functionality of the Preview2 and it was working

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.