Thread: help with simple code

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    3

    help with simple code

    I am just trying to make my own copy file command, and it doesnt seem to be working. Can someone help. With the attached code it only copies 7 bytes of the 56 byte picture (its a small picture). So whats up with this?
    Code:
    #include <iostream>
    #include <string>
    #include <fstream>
    using namespace std;
    int main ( int argc, int argv[] )
    {
          ifstream indata;
          ofstream outdata;
          indata.open("note.gif",ios::in | ios::binary);
          outdata.open("copy.gif",ios::out | ios::binary);
         
          char send_msg[100];
          indata.get(send_msg, 100);
          outdata<<send_msg;
    	
    
      return 0;
    }
    Last edited by Salem; 07-27-2004 at 01:18 PM. Reason: Added code tags - please remember to use them in future

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >indata.get(send_msg, 100);
    >outdata<<send_msg;

    You could use rdbuf():
    Code:
    outdata << indata.rdbuf();
    Or another idea is read(), followed by write().

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 14
    Last Post: 11-23-2005, 08:53 AM
  2. << !! Posting Code? Read this First !! >>
    By kermi3 in forum Windows Programming
    Replies: 0
    Last Post: 10-14-2002, 01:29 PM
  3. << !! Posting Code? Read this First !! >>
    By biosx in forum C++ Programming
    Replies: 1
    Last Post: 03-20-2002, 12:51 PM
  4. Simple Code, looking for input.
    By Alien_Freak in forum C Programming
    Replies: 3
    Last Post: 03-03-2002, 11:34 AM