chsize.c

来自「不错书对C++/C程序员很有用的大家不要错过.」· C语言 代码 · 共 20 行

C
20
字号
#include <stdio.h>
#include <io.h>        
#include <fcntl.h>     
#include <sys\types.h> 
#include <sys\stat.h>  

void main(void)
 {
    int handle;

    if ((handle = creat("100ZEROS.DAT", S_IWRITE)) == -1)
			fprintf(stderr, "Error opening 100ZEROS.DAT");
    else
     { 
       if (chsize(handle, 100L)) 
				printf("Error changing file size\n");
			close(handle);
     }
 }

⌨️ 快捷键说明

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