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!!

Recommended Answers

All 3 Replies

Member Avatar for iamthwee

>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

Looks to me like a homework assignement...
try using fstreams file>>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.