fread.c

来自「vc library 韩国语版 希望对大家又帮助」· C语言 代码 · 共 32 行

C
32
字号
#include <stdio.h>
#include <alloc.h>
#include <io.h>
#include <stdlib.h>
void main()
{
void *buf;
FILE *src;
FILE *dest;
long length;
buf=malloc(1000);
if (buf==NULL)
  {
  printf("out of memory");
  exit(1);
  }
src=fopen("c:\\autoexec.bat","rt");
if (src==NULL)
  {
  printf("file not found");
  exit(1);
  }
dest=fopen("c:\\autoexec.txt","w+");
length=filelength(fileno(src));
fread(buf,1,length,src);
fwrite(buf,1,length,dest);
free(buf);
fclose(src);
fclose(dest);
printf("%d bytes copied\n",length);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?