Thread: wierd error message

  1. #1
    Registered User
    Join Date
    Apr 2003

    wierd error message

    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
    #include <iostream>
    #include <fstream>
    #include <string>
    using namespace std;
    class packunpack
    	char lname[15];
    	char fname[15];
    	char email[36];
    	char stuid[15];
    	char buffer[65];
    	ofstream outfile("fixlength.txt");
    friend ostream& operator <<(ostream &stream, packunpack &p)
    	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(, 35);
        strcat(p.buffer, fixlng);
    	cout << p;
    	return stream;
    void main()
    	packunpack t;
    	fstream infile;"f.txt", ios::in);
    	infile >> t;
    Anyone have any idea whats going wrong here. I get error message
    error C2059 it says 'string' and that is it
    Last edited by drdodirty2002; 03-24-2005 at 11:44 PM.

  2. #2
    Join Date
    May 2004
    Well, knowing the error msg would make things simpler

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > ofstream outfile("fixlength.txt");
    My guess is it doesn't like instance information in a class declaration.

    > void main
    And everyone should object to this!
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. wierd struct error
    By sujeet1 in forum C Programming
    Replies: 5
    Last Post: 09-27-2007, 06:38 AM
  2. OpenGL Wierd **** - Order of Drawing Stuff?
    By Tonto in forum Game Programming
    Replies: 9
    Last Post: 11-09-2006, 09:56 PM
  3. Wierd chars...
    By mikahell in forum C++ Programming
    Replies: 8
    Last Post: 08-06-2006, 07:18 PM
  4. wierd errors
    By DeepFyre in forum C++ Programming
    Replies: 7
    Last Post: 12-21-2004, 09:32 PM
  5. This is wierd.
    By Ranedhel in forum C++ Programming
    Replies: 6
    Last Post: 12-12-2003, 03:26 PM