Any idea how can I copy file to multiple destination, like placing a file to multiple directories.
Tahnks
This is a discussion on copying to multiple destination within the Linux Programming forums, part of the Platform Specific Boards category; Any idea how can I copy file to multiple destination, like placing a file to multiple directories. Tahnks...
Any idea how can I copy file to multiple destination, like placing a file to multiple directories.
Tahnks
How about something like this
Code:#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { FILE *ifp, *ofp; int i, c; if (argc < 3) { printf("Args needed\nEG: mycopy source target1 target2 target3 ..."); return(EXIT_FAILURE); } if ((ifp = fopen(argv[1], "rb")) == NULL) { perror(argv[1]); return(EXIT_FAILURE); } for (i = 2; i < argc; i++) { printf("copying to %s\n", argv[i]); if ((ofp = fopen(argv[i], "wb")) == NULL) { perror(argv[i]); continue; } while ((c = fgetc(ifp)) != EOF && fputc(c, ofp) != EOF) ; if (ferror(ofp)) perror(argv[i]); if (ferror(ifp) || !feof(ifp)) perror(argv[1]); fclose(ofp); rewind(ifp); } fclose(ifp); return(EXIT_SUCCESS); }
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]