Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading three lines each time from text file

Status
Not open for further replies.

eustathi

Technical User
May 9, 2007
9
GR
Hello

I want to put into a struct three numbers from a text file
in which each number is in different line. I tested fgets to read line by line, but i cant think an efficient way to read three integers each time


For example

struct nums
{ int x,y,z; }

nums1={1,2,3} nums2={4,5,6}

text file:
1
2
3
4
5
6
 
Call fgets 3 times then, then extract 3 integers from those 3 lines.



--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top