Thread: write() function

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696

    write() function

    I managed to write type of string as following
    Code:
    ofstream& operator<<(ofstream& stream, const Data& d) {
        int len;
        char *str;
        str = new char[80];
        string name = "me";
    
        len = static_cast<int>(d.name.length());
        strncpy(str, name.c_str(), len);
        stream.write(reinterpret_cast<const char *>(&len), sizeof(int));
        stream.write(reinterpret_cast<const char *>(str), len);
        return stream;
    
        len = static_cast<int>(sizeof(d.num));
        stream.write(reinterpret_cast<const char *>(&len), sizeof(d.num));
        stream.write(reinterpret_cast<const char *>(d.num), len);
    }
    The overloaded operator above is supposed to work for:
    outFile << Data;
    But I cant get the d.num to print.

    any clue??
    Last edited by alphaoide; 10-02-2003 at 10:59 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Replies: 5
    Last Post: 02-08-2003, 07:42 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM