Txt file reading a data storing

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2008
Posts: 8
Reputation: radnik is an unknown quantity at this point 
Solved Threads: 0
radnik radnik is offline Offline
Newbie Poster

Txt file reading a data storing

 
0
  #1
Jun 15th, 2008
Hey guys i need some help. I have a txt file which looks like this:
234 56 123 34 456 56 7 45.....
123 3 34 56 56 67 67 2.....
.
.
.
Where each line represents a series of points in coordinate system, and the first number in each line represents the x-point, second y-point,third x-point and so on. I need to read the file, and store the data. I would like to store it in a structure:
struct path {

int x();
int y();
};
I would also need some kind of automatic variable naming for struct path, so when i begin to store second line of points i would have struct name path2. These are just my ideas, so if you can, please help with every approach you can think of. And when the data storing is done i should be able to know the total number of paths and total number of point pairs (x,y) for every path. If you have any ideas please help, i'm a begginer and really need to solve this problem. Thank you in advance!!
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 672
Reputation: Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold 
Solved Threads: 99
Sky Diploma's Avatar
Sky Diploma Sky Diploma is offline Offline
Practically a Master Poster

Re: Txt file reading a data storing

 
0
  #2
Jun 15th, 2008
You can start by defining your struct and posting down the code you have come up with until now.

Please Read This too:
http://www.daniweb.com/forums/announcement8-2.html
1. Please Mark Your Thread as Solved After Getting Your Answers.
2. Please Use CODE TAGS .
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Txt file reading a data storing

 
0
  #3
Jun 15th, 2008
>I would also need some kind of automatic variable naming for struct path, so when i begin to store second line of points i would have struct name path2.

I don't quite get why you need to differentiate between the separate lines.

It makes your code slightly more difficult
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 67
Reputation: Tigran is an unknown quantity at this point 
Solved Threads: 5
Tigran Tigran is offline Offline
Junior Poster in Training

Re: Txt file reading a data storing

 
0
  #4
Jun 15th, 2008
Looks to me like a homework assignement...
try using fstreams file>>
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC