文件复制,在Linux中,将生成的read.o 重新文件拷贝一份复制到ReadCopy.o中,并且更改ReadCopy.o文件的操作权限。使其能够正常运行。
实例代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include <stdio.h>
int main(){
FILE *r_file = fopen ( "read.o" , "rb" );
FILE *w_file = fopen ( "ReadCopy.o" , "w" );
char temp[10];
int judge = 0;
if (r_file){
do {
judge = fread (temp, sizeof ( char ),10,r_file);
if (!judge){
break ;
}
fwrite (temp, sizeof ( char ),10,w_file);
} while (1);
}
fclose (r_file);
fclose (w_file);
r_file = NULL;
w_file = NULL;
return 0;
}
|
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
原文链接:http://blog.csdn.net/worldmakewayfordream/article/details/21203123