![]() |
|
|
|||||||
| Home | Forums | Register | Rules & FAQ | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
Other UNIX.COM Threads You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| read the file line by line | kittusri9 | Shell Programming and Scripting | 3 | 04-24-2008 05:26 AM |
| How to read last line of a txt file? | yongho | UNIX for Dummies Questions & Answers | 2 | 06-13-2005 10:20 AM |
| Read a file line by line | VENC22 | UNIX for Dummies Questions & Answers | 2 | 05-12-2005 10:13 AM |
| read line from file | rein | Shell Programming and Scripting | 5 | 04-14-2005 11:32 PM |
| How to read from a file line by line and do stuff | spaceship | Shell Programming and Scripting | 4 | 03-17-2005 05:47 PM |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
How to read element of line of file
Hi,
I would like to get elements in data in a file. My file data would be something like:- foo 123.32 323 4356.234 22344.9 fon 234.454 3434 2362.3 34 ...etc.. I would like to read the elements in this file each line by line and write onto another text file. I am using getline to get these data from line by line basis. However, for element basis, I would like to use istream_iterator vector to store these values but im not sure how I could use that since vector only permits one type of data type. Instead, my data has mixture of string, float and ints data. Another alternative im thinking would be using istringstream obj(line) and then declare each element variable's data type before obj>>a>>b>>c>>d>>e But Im not too sure it is working or correct concept. Please help. Thanks. |
| Forum Sponsor | ||
|
|
|
|||
|
hi,
you can make use of stringtokenizer to help extract the values into "tokens". by default the delimiter to extract the value is "space" and also in this case all your values are seperated by space. hope this helps. ![]() |
|||
| Google UNIX.COM |