#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;
}
i know this a lame example but it kind of gives you an idea as to what i'm going for ):
i heard that it's possible to do this using char, a c based solution, but i'm not too familiar with it. any help is greatly appreciated.
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.