I want to be able to read a full line into a character array using a function.
example input text is:
Schmidt, Helga
Alvarez, Ruben
Zowkowski, Aaron
Huang, Sun Lee
Einstein, Beverly
However, im not sure how to read a full line of characters into the array. I know the delimiter for >> is whitespace, but I'm not sure if I change that delimiter to '\n' if it'd work?
void buildList(char (*array)[25], ifstream& inputFile){
string line;
for (int i = 0; i < 5; i++)
getline(inputFile, line);
array[i] = line.c_str();
}
Currently this only reads either a last name or first name into my input instead of the whole line. I'm not sure how I can go about changing this. Thanks.
cstrof any string.std::stringversion ofgetline, but if you absolutely insist on not, there are versions that are members of the streams that work with a rawcharbuffer here.