模拟notepad查看txt功能以及模拟复制文件的功能。
Linux。 cat和cp
#include<stdio.h>
#include<stdlib.h>
void main(int l_length, char **l_arr) {
if (l_length != 3) {
return;
}
FILE * l_fp_read = fopen(l_arr[1], "r");
FILE * l_fp_write = fopen(l_arr[2], "w");
if (l_fp_read != NULL) {
if (l_fp_write != NULL) {
char l_temp = getc(l_fp_read);
while (l_temp != EOF) {
putc(l_temp, l_fp_write);
l_temp = getc(l_fp_read);
}
fclose(l_fp_write);
}
fclose(l_fp_read);
}
}