help with simple code

This is a discussion on help with simple code within the C++ Programming forums, part of the General Programming Boards category; I am just trying to make my own copy file command, and it doesnt seem to be working. Can someone ...

  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, 07: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, 11:51 AM
  4. Simple Code, looking for input.
    By Alien_Freak in forum C Programming
    Replies: 3
    Last Post: 03-03-2002, 10:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21