// to use a file as input you must // include the fstream (file stream) library #include // and establish the filename for the file and get ready for input including positioning at the start of the file ifstream inFile(filename.c_str(),ios::in); // where filename is a string variable that the user has entered the correct filename for. // BTW, the data file must by in the project folder for the project // gets a line of text from the user or a file - putting the result into newVal where it is available for the caller // MAR - toStop defaults to end of line - '\n' - other stops could be used istream& mygetline(istream &strIn, string &newVal, char toStop = '\n') { char curr; newVal = ""; // get first char strIn.get(curr); // skip leading "white space" - new line, blank while ((curr == ' ') || (curr == '\n')) { strIn.get(curr); } // now get real chars while (curr != toStop) { // concatenate to the existing string then get next char newVal += curr; strIn.get(curr); } return strIn; }