#include "stdio.h"
int main(int argc, char *argv[]) {
if (argc < 2) {
printf("use command:[ cmd filename ]\n");
return 1;
}
FILE *fp = fopen(argv[1], "r");
if (!fp) {
perror("open file");
return 1;
}
char c;
while(~(c = fgetc(fp))) {
printf("%c", c);
}
fclose(fp);
return 0;
}
#include "stdio.h"
int main(int argc, char *argv[]) {
if (argc < 3) {
printf("use command:[ cmd srcFile dstFile ]\n");
return 1;
}
FILE *fp1 = fopen(argv[1], "r");
if (!fp1) {
perror("open srcFile");
return 1;
}
FILE *fp2 = fopen(argv[2], "w");
if (!fp2) {
perror("open dstFile");
return 1;
}
char c;
while(~(c = fgetc(fp1))) {
fputc(c, fp2);
}
fclose(fp1);
fclose(fp2);
return 0;
}