mv Command using system call in C++

I'm trying to move a file using mv command in C++. But I'm getting error.I've tried following code:

system("mv /home/comp-sl1-25/.local/share/Trash/files/"+filename" /home/comp-sl1-25/RecoveredFile");

I want to move a file(named 'filename'- its a string variable) from Trash folder to recovery folder.
Basically I'm trying to restore files from trash using c++. So if you have any other way to restore files from trash using c++ then also provide the code.
Thanks in advance :D
Last edited on
Do not use system() for that.

Read
man 2 rename

and
http://www.cplusplus.com/reference/cstdio/rename/
Last edited on
Like Keskiverto said, you shouldn't be using system() but as far as the issue look closely at your string "mv /home/comp-sl1-25/.local/share/Trash/files/"+filename" /home/comp-sl1-25/RecoveredFile" notice how after filename you are missing a +? Though this won't even fix the issue it will just fix how a string should be.
Last edited on
Topic archived. No new replies allowed.