0

Possible Duplicate:
How do I tokenize a string in C++?

Can sombody help me dividing a line in parts? I want to break the line at each ';', it is stored in myLine.

Example of a line: surname firstName;6;7;4;10;5;9;8;3;6;7;4;10;5;9;8;6;7;4;10;5;9;6;7;4;10;5;9;

fgets(line[i], LAENGE, datei);          
char* myLine = line[i]; 

I'm thankful for every tip! :)

Community
  • 1
  • 1
Baileys
  • 13
  • 3

1 Answers1

2
std::istringstream iss(myLine);
std::vector<std::string> v;
std::string current;
while(std::getline(iss, current, ';'))
   v.push_back(current));

I may have mixed up the parameter order in getline

Armen Tsirunyan
  • 130,161
  • 59
  • 324
  • 434