---
来源:互联网 发布:oracle需要使用的端口 编辑:程序博客网 时间:2024/04/30 13:00
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
int main()
{
int fd = 0;
char buf[32] = {'\0'};
int ret = 0;
ret = access("msg.txt", F_OK);
printf("%d\n",ret);
if (ret == 0)
{
printf("file exist\n");
fd = open("msg.txt", O_WRONLY);
if (fd < 0)
{
perror("open file error");
return 1;
}
while(1)
{
memset(buf, '\0', sizeof(buf));
ret = read(fd, buf, sizeof(buf) - 1);
if (ret < 0)
{
perror("read file error");
return 1;
}
if (ret == 0)
{
break;
}
printf("%s",buf);
}
}
else
{
}
close(fd);
return 1;
}
/*
int ts = tcsetattr(fd,TCSNOW,termios* _termios_p _termios_p);
struct termios
newattr.c_cflag &=~ CSIZE;
newattr.c_cflag 1= CS8;
necattr.c_cflag &= ~CSTOPB;//1位停止位
newattr.c_cflag &=~ PARENB;// 无校验
*/
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
int main()
{
int fd = 0;
char buf[32] = {'\0'};
int ret = 0;
ret = access("msg.txt", F_OK);
printf("%d\n",ret);
if (ret == 0)
{
printf("file exist\n");
fd = open("msg.txt", O_WRONLY);
if (fd < 0)
{
perror("open file error");
return 1;
}
while(1)
{
memset(buf, '\0', sizeof(buf));
ret = read(fd, buf, sizeof(buf) - 1);
if (ret < 0)
{
perror("read file error");
return 1;
}
if (ret == 0)
{
break;
}
printf("%s",buf);
}
}
else
{
}
close(fd);
return 1;
}
/*
int ts = tcsetattr(fd,TCSNOW,termios* _termios_p _termios_p);
struct termios
newattr.c_cflag &=~ CSIZE;
newattr.c_cflag 1= CS8;
necattr.c_cflag &= ~CSTOPB;//1位停止位
newattr.c_cflag &=~ PARENB;// 无校验
*/
0 0
- 程序员
- 程序员?
- 程序员
- 程序员
- 程序员
- 程序员
- 程序员
- 程序员
- 程序员
- 程序员
- 程序员
- 程序员
- 程序员
- 程序员
- 程序员
- 程序员
- 程序员
- 程序员
- doppler channle characteristic
- 使用jqMobi开发app基础:Badge的使用
- 配置数据发送邮件
- Reserved space protection
- 亲身经历:中型企业ERP选型全纪录
- ---
- 什么是非自然链接
- 7个方法可以让你成为更好的程序员
- ubuntu自动挂载磁盘分区
- 【伊利丹】Hadoop2.0 NN HA实验记录
- Binder 机制详解—Binder Java框架(转自Cloud Chou's Tech Blog)
- ios 8 发布后的一个初探swift语言的学习笔记(基本数据类型)
- 非常难得的iPad版房地产售楼助手应用
- web标准、可用性、可访问性 可维护性