Thread: How do you copy a file?

  1. #1
    Registered User
    Join Date
    Apr 2010
    Location
    Vancouver
    Posts
    132

    How do you know if your code is portable or not?

    How do you know if your code is portable or not? For example will the function rename in stdio.h work on always?
    Last edited by c_weed; 08-16-2012 at 05:56 PM. Reason: typo

  2. #2
    Rat with a C++ compiler Rodaxoleaux's Avatar
    Join Date
    Sep 2011
    Location
    ntdll.dll
    Posts
    203
    "How do you copy a file?"
    "How do you know if your code is portable or not?"

    I knew I shouldn't have eaten that expired ham.

    Yes, the functions in the standard library will be the same. They are the C++ standard.
    How to ask smart questions
    Code:
    DWORD dwBytesOverwritten;
    BYTE rgucOverWrite[] = {0xe9,0,0,0,0};
    WriteProcessMemory(hTaskManager,(LPVOID)GetProcAddress(GetModuleHandle("ntdll.dll"),"NtQuerySystemInformation"),rgucOverWrite,5,&dwBytesOverwritten);

  3. #3
    Registered User
    Join Date
    Apr 2010
    Location
    Vancouver
    Posts
    132
    So anything from the standard library is portable?

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by c_weed
    So anything from the standard library is portable?
    Yes, with two caveats:
    1. Compilers and standard library implementations have bugs.
    2. A freestanding implementation (e.g., pertaining to an embedded system) is only required to provide a certain subset of the C++ standard library. Beyond that, what is provided is implementation defined.
    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

  5. #5
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

    I'm not trying to scare you away from standard functions, but be aware though that not all implementations are created equally.

    See `strtok' and `ungetc' functions that vary widely in how well they do what they are supposed to do.

    Soma

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Copy an .exe to a new .exe file using C/C++
    By Avenger625 in forum C++ Programming
    Replies: 6
    Last Post: 02-07-2011, 12:49 AM
  2. Replies: 2
    Last Post: 03-04-2010, 04:19 AM
  3. copy file
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 08-02-2002, 01:02 PM
  4. copy file
    By juandy in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 10-05-2001, 02:37 PM