A
Amadeus W. M.
I'm trying to read a whole file as a single string, using the getline()
function, as in the example below. I can't tell what I'm doing wrong.
Tried g++ 3.2, 3.4 and 4.0. Thanks!
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;
int main(int argc, char * argv[])
{
const int MAX_SIZE=100000;
string s;
char chars[MAX_SIZE];
fstream IN("junk", ios::in);
// These 2 are ok.
IN.getline(chars, MAX_SIZE, EOF); // works, so EOF ok
getline(IN, s, 'x'); // works with string, no EOF
// g++ doesn't like this one.
getline(IN, s, EOF); // what's wrong??
return 0;
}
function, as in the example below. I can't tell what I'm doing wrong.
Tried g++ 3.2, 3.4 and 4.0. Thanks!
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;
int main(int argc, char * argv[])
{
const int MAX_SIZE=100000;
string s;
char chars[MAX_SIZE];
fstream IN("junk", ios::in);
// These 2 are ok.
IN.getline(chars, MAX_SIZE, EOF); // works, so EOF ok
getline(IN, s, 'x'); // works with string, no EOF
// g++ doesn't like this one.
getline(IN, s, EOF); // what's wrong??
return 0;
}