Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#include <stdlib.h>
int main(void)
{
system("copy file1+file2+file3 outfile");
return 0;
}
echo47 said:This should work fine:
I don't know about exec, there is no such thing in ANSI C.Code:#include <stdlib.h> int main(void) { system("copy file1+file2+file3 outfile"); return 0; }
Or were you asking how to generate a string with all those "file..." words in it?
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int n;
char buf[1000], *p;
/* This lacks checks for too-few arguments, or buffer-overflow */
p = buf + sprintf(buf, "copy");
for (n=1; n<argc; n++)
p += sprintf(p, "%c%s", (n==1 || n==argc-1 ? ' ' : '+'), argv[n]);
puts(buf); /* Change "puts" to "system" in the final version */
return 0;
}
echo47 said:I hope that wasn't your homework!Code:#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int n; char buf[1000], *p; /* This lacks checks for too-few arguments, or buffer-overflow */ p = buf + sprintf(buf, "copy"); for (n=1; n<argc; n++) p += sprintf(p, "%c%s", (n==1 || n==argc-1 ? ' ' : '+'), argv[n]); puts(buf); /* Change "puts" to "system" in the final version */ return 0; }