tom.c
来自「用五个实例来解释linux下的c编程」· C语言 代码 · 共 30 行
C
30 行
/* tom.c v2.0 */#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <stdlib.h>#include <stdio.h>#define FILE "message.txt"int main(){ int fd; char msg[] = "message.txt created by Tom.\n"; ssize_t s; /* Open file for write. */ fd = open(FILE, O_CREAT | O_TRUNC | O_WRONLY, 0666); if(fd < 0) { perror("open"); } /* Write message. */ s = write(fd, &msg, sizeof(msg)-1); /* Close file. */ close(fd); exit(EXIT_SUCCESS);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?