>C++I want to copy a file in /Program Files.#include <windows.h>using namespace std;int main(){system("copy C:\\Users\\%username%\\Desktop\\test.txt C:\\Program Filestest.txt");return 0;}It doesn't work.Halp /g/
#include <windows.h>using namespace std;int main(){system("copy C:\\Users\\%username%\\Desktop\\test.txt C:\\Program Filestest.txt");return 0;}
Fail#include <windows.h>using namespace std;int main(){system("copy C:\\Users\\%username%\\Desktop\\test.txt C:\\Program Files\\test.txt");return 0;}
#include <windows.h>using namespace std;int main(){system("copy C:\\Users\\%username%\\Desktop\\test.txt C:\\Program Files\\test.txt");return 0;}
>Windowslel
>>32265550 (OP)C:\\Program Filestest.txtThere's no backslash after "Files"Also, it might need to run as Admin
C:\\Program Filestest.txt
>using backslashes for directories
>>32265573Also, probably needs to besystem("copy C:\\Users\\%username%\\Desktop\\test.txt \"C:\\Program Files\\test.txt\"");
system("copy C:\\Users\\%username%\\Desktop\\test.txt \"C:\\Program Files\\test.txt\"");
>>32265602It doesn't work.Error : Command's syntax is invalid%Program Files% ?
Command's syntax is invalid
>>32265665mfw guy it worksThanks !
>>32265573>>32265665Does it not need to be Program\ Files or am I mixing up Linux and Windows?
>using system()Copy the damn file and stop using C++ as a fucking shell scripting language.
>>32265550 (OP)Don't use the system function.In this case, don't even use C++, just write a shell script.