C語言文件復制實例詳解
文件復制,在Linux中,將生成的read.o 重新文件拷貝一份復制到ReadCopy.o中,并且更改ReadCopy.o文件的操作權限。使其能夠正常運行。
實例代碼:
#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; }
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答
圖片精選