Hey... I always hear that it's considered bad to use system commands. It seems like you sometimes have to use a dos or unix command! However, I have also noticed that you can't use a string variable to call the system command.
Gives an error:
Doesn't give an error:Code:#include <stdlib.h> #include <iostream.h> int main() { char SystemCommand[] = "copy C:\file.txt C:\newfolder\file.txt"; system(SystemCommand); return 0; }
Is there a way to use a string variable to call a system command, like I wanted to in the first code block?Code:#include <stdlib.h> #include <iostream.h> int main() { system("copy C:\file.txt C:\newfolder\file.txt"); return 0; }
Thanks,
The_Muffin_Man