Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,676 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,200 people online right now. Registration is fast and FREE... Join Now!




File reading

 
Reply to this topicStart new topic

File reading

aj32
post 31 Aug, 2007 - 01:31 PM
Post #1


D.I.C Addict

Group Icon
Joined: 30 Aug, 2007
Posts: 577



Thanked 2 times

Dream Kudos: 675
My Contributions


I am writing a program in C++ that needs access to files to determine and store user options, write now the program uses a separate file for each option rolleyes.gif
What I want to do is store the option data in one file, keep each line of the file for a different option then have the program read the file and store each line as a separate variable.
-Thanks
User is offlineProfile CardPM

Go to the top of the page

Martyr2
post 31 Aug, 2007 - 02:01 PM
Post #2


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 5,062



Thanked 175 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


Then I recommend you go with an INI file format which lends itself to program configuration settings. The way this is structured will allow you to not only look up sequentially but also jump to specific sections like an index if the need ever arises.

You can check out the wikipedia article on this file type to get an idea how it might work for you.

Wikipedia article on INI file format for storing program settings
User is offlineProfile CardPM

Go to the top of the page

BitNinja
post 2 Sep, 2007 - 11:53 PM
Post #3


New D.I.C Head

*
Joined: 27 Aug, 2007
Posts: 7


My Contributions


I recommend .csv extension file. You can I/O variable in separate line.
Easy to modify and very light
User is offlineProfile CardPM

Go to the top of the page

aj32
post 4 Sep, 2007 - 11:42 AM
Post #4


D.I.C Addict

Group Icon
Joined: 30 Aug, 2007
Posts: 577



Thanked 2 times

Dream Kudos: 675
My Contributions


Ok, I looked at the article at wikipedia, but how do you work with .INI files in C++?
-Thanks
User is offlineProfile CardPM

Go to the top of the page

Bench
post 4 Sep, 2007 - 12:37 PM
Post #5


D.I.C Addict

Group Icon
Joined: 20 Aug, 2007
Posts: 602



Thanked 10 times

Dream Kudos: 150

Expert In: C/C++

My Contributions


There are only two types of files as far as C++ is concerned - Binary files, where you read a byte at a time, and build objects from the ground up,
or text files, where you read a line or character at a time, and parse strings for tokens & symbols.

How you do anything with the data after that (text files are far easier), is up to you. The easiest way is to set up some simple rules about what format the data will be stored in, and tokenise the input from there.
User is offlineProfile CardPM

Go to the top of the page

no2pencil
post 4 Sep, 2007 - 12:47 PM
Post #6


My fridge be runnin OH NOEZ!

Group Icon
Joined: 10 May, 2007
Posts: 6,354



Thanked 58 times

Dream Kudos: 2375

Expert In: Goofing Off

My Contributions


QUOTE(aj32 @ 4 Sep, 2007 - 12:42 PM) *

Ok, I looked at the article at wikipedia, but how do you work with .INI files in C++?
-Thanks

It's called "Data Parsing".
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/23/08 06:29AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month