Connecting Tech Pros Worldwide Forums | Help | Site Map

how to use struct function

Newbie
 
Join Date: Oct 2006
Posts: 3
#1: Oct 13 '06
how to use struct function as it pertains to reading data from a file and storing it ?
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,166
#2: Oct 13 '06

re: how to use struct function


There is no such thing as a "struct function", please be clearer in your question.
D_C D_C is offline
Needs Regular Fix
 
Join Date: Jun 2006
Posts: 294
#3: Oct 13 '06

re: how to use struct function


How can he use a function to read data from a file into a struct?

Pass by reference a data structure to read in the data, and pass by value/reference a string or some way to identify the file to read. You may want to return a boolean value, true if everything went alright, false if something went wrong.

I'll put the very basics. I can't get too specific unless you give an example of the data and how it should be parsed.

Basics:
In the function, open the file for reading.
Figure out how to parse the data.
Take each line and store it appropriately in the data structure.
Close the file.
Reply