How would one go about reading in a line of characters from a file. First the program reads in an integer from the file. That number indicates how many characters to read in in
To answer your question:
#include
using namespace std;
int main() {
ifstream f("file.txt");
int n;
f >> n;
char chs = new char[n];
for (int i = 0; i < n; ++i) f >> chs[i];
// do something about chs
delete [] chs;
}
But, I would go with (if your Michael
appears on its own line):
#include
#include
using namespace std;
int main() {
ifstream f("file.txt");
int n;
f >> n;
string str;
getline(f, str);
}