Using getline() with file input in C++
getline
, as it name states, read a whole line, or at least till a delimiter that can be specified.
So the answer is "no", getline
does not match your need.
But you can do something like:
inFile >> first_name >> last_name >> age;
name = first_name + " " + last_name;
you should do as:
getline(name, sizeofname, '\n');
strtok(name, " ");
This will give you the "joht" in name then to get next token,
temp = strtok(NULL, " ");
temp will get "smith" in it. then you should use string concatination to append the temp at end of name. as:
strcat(name, temp);
(you may also append space first, to obtain a space in between).