Assuming you already know how to read an entire line of a text file, you could delimit the text with a specific char (i use ',' a lot).
Fore example you could read the first line in "Peter He is a boy." but if you were to set it up as a delimited string it can look like this "Peter,He is a boy.". then you can loop through each char of the string till the particular char in question = ',' and you can then split the string accordingly.
Something like this may what you're looking for:
#include <string>
#include <sstream>
#include <vector>
int main()
{
vector<string> lines(3);
vector<string> names(3);
vector<string> descriptions(3);
lines.at(0) = "Peter,He is a boy.";
lines.at(1) = "Mary,She is a girl.";
lines.at(2) = "Tom,It is a cat.";
for(int i = 0; i < lines.size(); i++) {
for(int j = 0; j < lines[i].size(); j++) {
if(lines[i][j] == ',') {
for(int d = 0; d < j; d++) {
stringstream ss;
ss << lines[i][d];
ss >> names.at(i);
}
for(int d = j + 1; d < lines[i].size(); d++) {
if(lines[i][d] != '.') {
stringstream ss;
ss << lines[i][d];
ss >> descriptions.at(i);
} else {
break;
}
}
break;
}
}
}
}
EDIT: This code will look for 3 spaces instead of a single char ','.
#include <string>
#include <sstream>
#include <vector>
int main()
{
vector<string> lines(3);
vector<string> names(3);
vector<string> descriptions(3);
lines.at(0) = "Peter,He is a boy.";
lines.at(1) = "Mary,She is a girl.";
lines.at(2) = "Tom,It is a cat.";
for(int i = 0; i < lines.size(); i++) {
for(int j = 0; j < lines[i].size(); j++) {
if(lines[i][j] == 0x20 && lines[i][j + 1] == 0x20 && lines[i][j + 2] == 0x20) {
for(int d = 0; d < j; d++) {
stringstream ss;
ss << lines[i][d];
ss >> names.at(i);
}
for(int d = j + 3; d < lines[i].size(); d++) {
if(lines[i][d] != '.') {
stringstream ss;
ss << lines[i][d];
ss >> descriptions.at(i);
} else {
break;
}
}
break;
}
}
}
}