fileno.c
来自「vc library 韩国语版 希望对大家又帮助」· C语言 代码 · 共 38 行
C
38 行
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <alloc.h>
#include <stdlib.h>
void main()
{
int handle;
FILE *stream;
int offset=0;
int length;
void *buf;
buf=malloc(60000);
if (buf==NULL)
{
printf("out of memory");
exit(1);
}
stream=fopen("c:\\autoexec.bat","rt");
if (stream==NULL)
{
printf("open failed");
exit(1);
}
handle=fileno(stream);
length=read(handle,buf,60000); // 佬绢 甸烙
if (length==-1)
{
printf("reading error");
exit(1);
}
for (offset=0;offset<length;offset++) // 免仿
putchar(((char *)buf)[offset]);
close(handle);
fclose(stream);
free(buf);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?