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

Join 136,367 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,667 people online right now. Registration is fast and FREE... Join Now!




info on creating and reading files

 
Reply to this topicStart new topic

info on creating and reading files

zerogee
3 Sep, 2008 - 07:10 PM
Post #1

New D.I.C Head
Group Icon

Joined: 20 Aug, 2008
Posts: 49

I am having a hard time understand writing and reading files. i have read a lot of literature but i can't seem to find the answers i'm looking for.

some facts; lets say i am writing a file of 5 records in an array. each record has 3 elements. let say i write the file with each element as a string. now my question;

1. without knowing how the file was written (ie...string, int, char, double) or the name of the element (or the format of those elements), but i do know the number of records and what each element (but not the order of these elements) are. how can you read a file in a program and load it into an array?

2. i assume when the file is written some tags are attached to each element but just not displayed in the .dat file?

i wrote a file like this and this was the dat in the .dat file;

1111frank26354
9847tom37374
5343hank1324

etc.... is this how a program writes a file?

i hope i am making sense.
User is offlineProfile CardPM
+Quote Post

gabehabe
RE: Info On Creating And Reading Files
4 Sep, 2008 - 01:51 AM
Post #2

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,526



Thanked: 98 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
Try looking up fstream.

Here:
http://www.cplusplus.com/doc/tutorial/files.html

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 09:34AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month