Help to copy files in c++

This is a discussion on Help to copy files in c++ within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by EVOEx Wouldn't this be valid and faster: Code: out << in.rdbuf(); I might be wrong, but I ...

  1. #46
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by EVOEx View Post
    Wouldn't this be valid and faster:
    Code:
    out << in.rdbuf();
    I might be wrong, but I think that is bound to copy each byte properly... Any thoughts?
    It may well do the right thing, but it's certainly not going to be very efficient, as discussed above. And it's likely that it won't work right for control characters like CR ('\r') and CTRL-D/Z (EOF indicator on text files). It may well work OK if you open the file in binary mode, but I doubt << operator is guaranteed for binary input.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  2. #47
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,781
    We covered this sometime ago in the thread reading text.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #48
    Registered User
    Join Date
    Nov 2008
    Posts
    36
    So, how exactly do I include files in a c++ .exe?

  4. #49
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by Helgso View Post
    So, how exactly do I include files in a c++ .exe?
    Why do you want to do that? What problem are you trying to solve by doing it?
    I've never tried to write a self-extracting .exe file, but I'm sure it's not an easy task.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  5. #50
    Registered User
    Join Date
    Nov 2008
    Posts
    36
    Quote Originally Posted by cpjust View Post
    Why do you want to do that? What problem are you trying to solve by doing it?
    I've never tried to write a self-extracting .exe file, but I'm sure it's not an easy task.
    Aww, do you know of any setup program that you can make it copy files from itself to a location? I know installshield and stuff but don't I have to buy that? And, I'm not looking for a program that creates f.x. startmenu shortcuts or shortcuts of any kind nor registry entries.

    Just that it will copy files from itself to a location. Do you know such program?

  6. #51
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,781
    Quote Originally Posted by Helgso
    Aww, do you know of any setup program that you can make it copy files from itself to a location? I know installshield and stuff but don't I have to buy that? And, I'm not looking for a program that creates f.x. startmenu shortcuts or shortcuts of any kind nor registry entries.

    Just that it will copy files from itself to a location. Do you know such program?
    You can create such a self-extracting archive using 7-zip.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #52
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,651
    Or try NSIS

  8. #53
    Registered User
    Join Date
    Nov 2008
    Posts
    36
    But how about a program that includes the .exe and the source files? When that exe is executed that includes all files, it will simply execute the exe within it?

Page 4 of 4 FirstFirst 1234
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with loading files into rich text box
    By blueparukia in forum C# Programming
    Replies: 3
    Last Post: 10-19-2007, 12:59 AM
  2. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  3. fopen vs. _open (for BIG image files)
    By reversaflex in forum C Programming
    Replies: 3
    Last Post: 04-01-2007, 12:52 AM
  4. Copy files
    By ErikDN in forum C Programming
    Replies: 1
    Last Post: 10-09-2004, 07:50 PM
  5. reinserting htm files into chm help files
    By verb in forum Windows Programming
    Replies: 0
    Last Post: 02-15-2002, 08:35 AM

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