| | |
Txt file reading a data storing
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2008
Posts: 8
Reputation:
Solved Threads: 0
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!!
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!!
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
Please Read This too:
http://www.daniweb.com/forums/announcement8-2.html
>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
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*
![]() |
Similar Threads
- contact info in array of structs (C++)
- problems with reading in file (C++)
- Data consolidation across an array a.k.a. Hashed to death... heeelp... (Perl)
- .txt/array problems (C++)
- only a couple of hours to go... (C++)
- Noob : Input Stream Trouble (Java)
Other Threads in the C++ Forum
- Previous Thread: help in figuring this out please
- Next Thread: what will i do to output low temp
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings struct temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






