bin_file_copy_test.cpp
来自「本程序介绍了如何用C语言快速读写磁盘文件。」· C++ 代码 · 共 34 行
CPP
34 行
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void bin_file_copy_test()
{
FILE *fp_in,*fp_out;
unsigned char ch;
if( (fp_in = fopen( "E:\\C++_sample\\File_operating\\bin_file_test.m4v", "rb" )) == NULL )
{
printf("cannot open the file bin_file_test.m4v\n");
exit(0);
}
if( (fp_out = fopen( "E:\\C++_sample\\File_operating\\copy_bin_file.m4v", "wb" )) == NULL )
{
printf("cannot open the outfile\n");
exit(0);
}
while(1)
{
ch = fgetc(fp_in);
if( feof(fp_in) ) //feof function returns "non_zero" when fp overflows in file,that is,
break; //if fp is located in the end of file and fp moves to next element
fputc( ch, fp_out );//again,then fp overflows.
}
fclose(fp_in);
fclose(fp_out);
return;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?