Thread: Help to copy files in c++

  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
    28,413
    We covered this sometime ago in the thread reading text.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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
    28,413
    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.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #52
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    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?

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, 09:35 AM