#include <iostream>
#include <fstream>
#include <string>
int main()
{
string firstName;
string lastName;
ifstream textFile;
textFile.open("galt.dat")
// what code do i use here to ignore "Hello" and "Mr."?
// do i use cin.ignore/cin.get here?
textFile >> firstName;
textFile >> lastName;
cout << "Hello Mr. " << firstName << ' ' << lastName << ".\n";
return 0;
}
Reading a file bit by bit isn't efficient if you're eventually going to read the entire thing anyways. More often than not, you'll have to read the entire file anyways to know what's useless and what's not.
It's also easier to think about. You read in a file of data into memory. You feed that data to a function as input which should parse and spit out useful data at you as output (then optionally feed that output to various other functions). Then you can use that data however you want.