lundi 29 août 2016

Text file has 1 or 2 or 3 strings followed by doubles. How do I read strings?(each line has 1 or 2 or 3 string in the beginning)

I'm still new to c++(and to stackoverflow). I'm creating program to analyze some data for me(open file, save data into vectors, then I search vectors for name, and then I work with objects functions). Anyways, previous "version" of the program works fine, but file that I open only contains 1 string per line in the beginning(followed by other data), so it's easy to work with. What I'm trying to do, is to open up the files that contain 1-3 strings(i.e. line 1 - West Ham United, line 2 - Everton etc.). After the name, other data follows on the same line. I thought about separating the name and other data into 2 lines, in example Line1 - name, Line2 - other data, and so on. But how do I save the whole "name" line into vector(vector is of the object type). Other option would be to open up the file and saving all of the chars into an array. Afterwards I would output that array in Outfile, deleting the spaces only between letters(i.e. - WestHamUnited), and then I would work with the output file. Question is, how do I delete the spaces only between letters? Maybe you guys could recommend some other option that I'm not aware of.

Aucun commentaire:

Enregistrer un commentaire