Beginner C/C++

Moderators: None (Apply to moderate this forum)
Number of threads: 5428
Number of posts: 16943

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Help reading from a file in C Posted by Kotik on 8 Oct 2012 at 3:23 AM
I'm trying to write a C program that takes 3 different inputs from the user (name, day, year) and then I fwrite it into a binary file in the following format "Name | day | year". Nothing complicated so far, its just "%s | %s | %s".

However I also want the user to be able to access information from the said binary file. I,e the user can get a list of all the names. How would I go about so that the program reads the binary file and reads the "Name | day | year" and stores each of the elements into an array. (I want it to be an array so I can sort the names alphabetically (but that is another issue).

Writing into the file seems relatively straight forward but I have no idea how to read from the file with the " | " dividing each parameter.

Thanks in advance
Thread Tree
Kotik Help reading from a file in C on 8 Oct 2012 at 3:23 AM
WaltP Re: Help reading from a file in C on 8 Oct 2012 at 2:41 PM
Kotik Re: Help reading from a file in C on 9 Oct 2012 at 5:19 AM



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.