Connecting Tech Pros Worldwide Forums | Help | Site Map

Reading from File

Newbie
 
Join Date: Apr 2007
Posts: 9
#1: Oct 8 '07
Hey all, I am having trouble remembering how to read things in from a file.

I have a structural array set so if I am correct, each element in the array has the things I put into my struct.

have have 3 things in my struct.
2 strings
1 float



The file I am trying to read from has first name, last name, and salary and each entry is seperated on their own lines.

I need to be able to take the first name and place it into my first string in my first element in my array.

I understand its something like
array[0].string1

to place the first name in the first string.

I am having trouble remembering how to read from the file from the first char to white space.


thanks for all the help!!!

gpraghuram's Avatar
Expert
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,258
#2: Oct 9 '07

re: Reading from File


Quote:

Originally Posted by huzzaa

Hey all, I am having trouble remembering how to read things in from a file.

I have a structural array set so if I am correct, each element in the array has the things I put into my struct.

have have 3 things in my struct.
2 strings
1 float



The file I am trying to read from has first name, last name, and salary and each entry is seperated on their own lines.

I need to be able to take the first name and place it into my first string in my first element in my array.

I understand its something like
array[0].string1

to place the first name in the first string.

I am having trouble remembering how to read from the file from the first char to white space.


thanks for all the help!!!

If the entry is separated by space then you can use fscanf which will read token by token.

Raghuram
Reply