Is it possible to make a console application that copies a specified file to another drive? for example to copy C:\useless.txt to A:\
Please if anyone knows how to do it of its even possible.... reply.
Thanx
Is it possible to make a console application that copies a specified file to another drive? for example to copy C:\useless.txt to A:\
Please if anyone knows how to do it of its even possible.... reply.
Thanx
|:|::...<<VooDoo>>...::|:|
?Code:#include <stdio.h> int main() { system("copy file.txt a:\file.txt"); return 0; }
Im using Dev C++ and it gives me 1 error "implicit declaration of function 'int system(...)'
|:|::...<<VooDoo>>...::|:|
It's in stdlib.h
Point your cursor at the function name and press F1
now it complies without errors but then in the console window it says: The system cannot find the specified file.
I have the file.txt in the directory but it just wont work. this is the code im using
----------------------------------------------------------
#include <stdlib.h>
int main()
{
system("copy file.txt a:\file.txt");
system("PAUSE");
return 0;
}
------------------------------------------------------------
|:|::...<<VooDoo>>...::|:|
It Works Now Thanx. i just had to take the file.txt out of "a: file.txt" for future reference the code is.
#include <stdlib.h>
int main()
{
system("copy file.txt a:");
return 0;
}
Last edited by VooDoo; 07-20-2002 at 02:50 PM.
|:|::...<<VooDoo>>...::|:|
It also works on folders.
Thought i would let you knowCode:#include <stdlib.h> int main() { system("copy test a:"); system("PAUSE"); return 0; }
Test being your folder.
Only problem i have found it doesn't copy the folder.
Also i would like to ask.... would it be possible to be able to make a program that would copy files to a CD-RW? Must be a way but i don't know how.
Last edited by ChrisMUK; 07-20-2002 at 04:48 PM.
I wrote a copy program here for someone asking about it on the C board.
It does the copy using standard C coding (expect for assuming you have backslashes as directory markers in the filenames, which obviously won't work on a *nix box). It's a bit safer than calling system, although a lot more long winded.
It's not guarenteed to be bullet proof, but it's a start.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
If youre going to use \ in a program, double it ( \\) or else it will be called an unknown escape ¿function?
.
I take it you mean this line:Originally posted by civix
If youre going to use \ in a program, double it ( \\) or else it will be called an unknown escape ¿function?
>if ((p = strrchr(in, '\\')) == NULL)
The thing is, I did use 2, I wouldn't post code that is that badly broken
But the board transposed it to a single slash for some reason. So I've edited the post and put 3 slashes in the source of my post, just to make it display 2 to everyone else
Thanks for pointing it out, at least I know to be careful of this in the future.
Code:Testing : 1 slash : '\' Testing : 2 slashes : '\\' Testing : 3 slashes : '\\\' Testing : 4 slashes : '\\\\'
Last edited by Hammer; 07-25-2002 at 04:33 AM.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]