| user24 11 (2) | ||||
|
This is about a college assignment. I have to extract the data from several lines and store them in suitable memory locations. The lines are:
As you can notice, there are spaces at the start of every line and I need to use the getline function with a delimiter ' ' (white space). Right now, all I have is:
Its all included in a loop but I am still not sure how to code that part. The current result I get is, the array fills up with white spaces. Any help will be very appreciated :) EDIT: Each complete line is already stored in a string variable. | ||||
|
Last edited on
|
||||
| jlb (170) | |
|
What type of variable is array? What do each of the "fields" in your file represent? For example the third field appears to be either the first name or the complete name. Please post your current code. | |
|
Last edited on
|
|
| toum (205) | |
| Use stringstreams and the >> operator. It will automatically get rid of the white spaces. | |
|
|
|
| user24 11 (2) | |||
|
Thanks a lot for all your replies. Here is the complete txt file :
I have to read the text file and store each of the details in a structure (struct). Above, I tried to use the getline function but it seems to be complicating things for me...any help? Maybe I should you sub strings? And could you please elaborate on this? I am very inexperienced at coding :P
toum: I already extracted the entire line into a string. I can do this for all the lines one by one. I just need to know how to separate out the variables and store them in a string array or struct perhaps. | |||
|
Last edited on
|
|||