creatnew,一個函式名稱,功能為 創建一個新檔案,用 法: int creatnew(const char *filename, int attrib);
基本介紹
- 外文名:creatnew
- 功 能:創建一個新檔案
- 用 法:int creatnew(const char
- 程式例::#include
函式名: creatnew
功 能: 創建一個新檔案
用 法: int creatnew(const char *filename, int attrib);
程式例:
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <dos.h>
#include <io.h>
int main(void)
{
int handle;
char buf[11] = "0123456789";
/* attempt to create a file that doesn't already exist */
handle = creatnew("DUMMY.FIL", 0);
if (handle == -1)
printf("DUMMY.FIL already exists.\n");
else
{
printf("DUMMY.FIL successfully created.\n");
write(handle, buf, strlen(buf));
close(handle);
}
return 0;
}