Hi there everyone I'm trying to output an array to a text file but for some reason I keep getting an error message. Would anyone have any advice
Anyone have any idea whats going wrong here. I get error messageCode:#include <iostream> #include <fstream> #include <string> using namespace std; class packunpack { private: char lname[15]; char fname[15]; char email[36]; char stuid[15]; char buffer[65]; ofstream outfile("fixlength.txt"); public: friend ostream& operator <<(ostream &stream, packunpack &p) { output<<p.buffer<<endl; return stream; } friend istream& operator >>(istream &stream, packunpack &p) { char buffer[60]; char fixlng[5]={" "}; stream.getline(p.lname, 15, '\n'); strcpy(buffer, p.lname); strcat(buffer, fixlng); stream.getline(p.fname, 15, '\n'); strcat(p.buffer, p.fname); strcat(p.buffer, fixlng); stream.getline(p.stuid, 15, '\n'); strcat(p.buffer, p.stuid); strcat(p.buffer, fixlng); stream.getline(p.email, 35); strcat(p.buffer, p.email); strcat(p.buffer, fixlng); cout << p; return stream; } }; void main() { packunpack t; fstream infile; infile.open("f.txt", ios::in); while(!infile.eof()) { infile >> t; } infile.close(); }
error C2059 it says 'string' and that is it



LinkBack URL
About LinkBacks


