Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Dynamic memory allocation:Reading a file into buffers using a single linked list!
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Hemanth, post: 2429734"] I want to read a file using fread() and then put it in to memory. I ......I believe, a queue implementation suits well for this case (for eg. if you want to process file with size larger than main memory, you have to read it in chunks of constant size and store it in a buffer). Here the queue can act as a buffer. Queue can be implemented using a single linked list (maintain both first and last pointers, always add nodes at Last and remove First Node --FIFO) Eg. struct node { char* buffer; //Replace char* with whatever you want struct node* first; struct node* last; }; - Construct a queue with "n" nodes; - Remove first node (process data and clear buffer) - Read another chunk of data from file and add it as a last node in queue. You can keep loop the last two steps. .......search for a Queue implementation on google. - Hemanth [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Dynamic memory allocation:Reading a file into buffers using a single linked list!
Top