We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,194 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Reading from .txt file into arrays in C?

Hi, i want to read each of the 4 columns stored in a .txt file separated by a space into an array of their own. The text file may have hundreds of rows so reading until the end of file is desirable.

Example:

3.4407280e+003 6.0117545e+003 8.0132664e+002 2.5292922e+003
3.4163843e+003 5.9879421e+003 7.7792044e+002 2.5058547e+003

so typically it would be array 1 containing all the rows from the first and most left column and so on..

Please help... thanks

2
Contributors
1
Reply
16 Hours
Discussion Span
1 Year Ago
Last Updated
3
Views
stephenhawkings
Newbie Poster
1 post since May 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

So, what have you done in the past 16 hours to solve this? (It's been 16 hours since you posted this question). Do you need all the data in memory at the same time, or can you work with one row of data at a time? The difference is the size of array that will be needed. After you determine that, it is pretty simple to read the numbers into an array by just calling fscanf() in a loop.

Ancient Dragon
Achieved Level 70
Team Colleague
32,139 posts since Aug 2005
Reputation Points: 5,836
Solved Threads: 2,577
Skill Endorsements: 69

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.2841 seconds using 2.66MB