in C how would i make a program copy itself to a certain folder? i cant use the
system("copy %0 etc..."); command, it doesnt work, know of any command that would work?
thank you
in C how would i make a program copy itself to a certain folder? i cant use the
system("copy %0 etc..."); command, it doesnt work, know of any command that would work?
thank you
also, (sorry for such dumb questions, i just started C, i used to program in Perl and my C book isnt giving me much help)
how do i make my program write to a file then save it at a certain place? do i use the fprintf?
thank you
What compiler you are using? I am not sure if system() command works on microsoft platforms. And from "copy" it looks like microsoft platform. Anyways, its a very expensive command.
Instead you could open the file and copy and write the bytes in binary mode if it executable.
Anoop.
i am using dev c++
o and most system commands work on windows platform, but the copy %0 doesnt...
i understand the copy function, but how can i get the copy function to reconize the program without giving its pathname, (this is going to be a small installer program) so i wont know where the program will be.... so thats why i am asking is there a C command/function like the batch copy %0 command?
no not the name, is there a way to have the program reconize itself then copy itself to a desntination folder??? or can i use that, then add the filename to a string or whatever then have the program copy the program from that string to a folder?
salem? code like that coming from you. What if the file name is extremely long?Originally posted by Salem
%0 is more like a DOS batch file parameter substitution.
In C, do something like
Code:char cmd[100]; sprintf( cmd, "copy %s %s", file1, file2 ); system( cmd );
>salem? code like that coming from you. What if the file name is extremely long?
Aside from there being several ways to do just about anything, telling somebody to do "something like" this or that gives us a bit of leeway in the perfection of an example. I've found it saves time. No doubt Salem has also.In C, do something like
My best code is written with the delete key.
can someone please answer my question?
thank you
>can someone please answer my question?
Someone did answer your question. Did you read the replies? Or were you expecting us to write this for you?
My best code is written with the delete key.
no...
they put how to get the name of the program but not how to make the program copy itself... sorry if im being rude or anything...
>they put how to get the name of the program but not how to make the program copy itself...
Maybe I'm seeing something that isn't there, but it sure looks like your question was answered completely.
In C, do something like
Code:char cmd[100]; sprintf( cmd, "copy %s %s", file1, file2 ); system( cmd );all the bits you need are in several replies in this thread
My best code is written with the delete key.