system() copy fails, while cmd copy works

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2008-10-26T07:51:31Z Indexed on 2010/05/06 4:18 UTC
Read the original article Hit count: 232

Filed under:
|
|
|
|

In cmd.exe, I can execute the command "copy c:\hello.txt c:\hello2.txt" and it worked fine. But in my C program, I ran this piece of code and got the following error:

#include <iostream>

using namespace std;

int main()
{
    system("copy c:\hello.txt c:\hello2.txt");
    system("pause");

    return 0;
}

Output: The system cannot find the file specified.

Anybody know what is going on here?

© Stack Overflow or respective owner

Related posts about c

    Related posts about system