mirror of
https://github.com/riba2534/TCP-IP-NetworkNote.git
synced 2026-02-02 17:48:55 +08:00
17 lines
392 B
C
17 lines
392 B
C
#include <stdio.h>
|
|
#include <fcntl.h>
|
|
|
|
int main()
|
|
{
|
|
FILE *fp;
|
|
int fd = open("data.dat", O_WRONLY | O_CREAT | O_TRUNC); //创建文件并返回文件描述符
|
|
if (fd == -1)
|
|
{
|
|
fputs("file open error", stdout);
|
|
return -1;
|
|
}
|
|
fp = fdopen(fd, "w"); //返回 写 模式的 FILE 指针
|
|
fputs("NetWork C programming \n", fp);
|
|
fclose(fp);
|
|
return 0;
|
|
} |