使用文件输出hello
来源:互联网 发布:淘宝卖空军一号真的吗 编辑:程序博客网 时间:2024/06/09 21:50
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#define BUFFER_SIZE 50
int main()
{
int fd;
int i,bytes_write;
int len;
char *ptr;
char buffer_write[BUFFER_SIZE] = "hello!";
if((fd = open(buffer_print,O_WRONLY|O_CREAT)) == -1)
{
perror("open from file");
exit(-1);
}
for(i = 0; i < 3; i++)
{
ptr = buffer_write;
len = strlen(buffer_write);
while(bytes_write = write(fd,ptr,len))
{
if((bytes_write == -1) && (errno != EINTR) )
{
break;
}
else if(bytes_write == len)
{
break;
}
else if(bytes_write > 0)
{
ptr += bytes_write;
len -= bytes_write;
}
}
printf("\n");
}
close(fd);
return 0;
}
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#define BUFFER_SIZE 50
int main()
{
int fd;
int i,bytes_write;
int len;
char *ptr;
char buffer_write[BUFFER_SIZE] = "hello!";
if((fd = open(buffer_print,O_WRONLY|O_CREAT)) == -1)
{
perror("open from file");
exit(-1);
}
for(i = 0; i < 3; i++)
{
ptr = buffer_write;
len = strlen(buffer_write);
while(bytes_write = write(fd,ptr,len))
{
if((bytes_write == -1) && (errno != EINTR) )
{
break;
}
else if(bytes_write == len)
{
break;
}
else if(bytes_write > 0)
{
ptr += bytes_write;
len -= bytes_write;
}
}
printf("\n");
}
close(fd);
return 0;
}
0 0
- 使用文件输出hello
- 使用vuejs输出Hello world
- 使用reactjs输出Hello world
- 使用Secure CRT 输出一个hello world!
- 第一讲 使用JNI输出“Hello World!”
- c程序中不使用分号输出"Hello, world"
- C#控制台 使用struct结构,输出hello world
- C++之第一个程序Hello World,使用IO库输出Hello World
- C#控制台 输出hello world之 使用分部类(使用分部方法)输出
- 使用iText输出PDF文件
- 使用递归 输出文件树
- 使用pyExcelerator输出Excel文件
- 使用输出流读取文件
- 使用文件输入与输出
- 输出"HELLO WORLD" ASM
- 汇编程序输出“Hello world”
- django输出 hello world
- php 输出Hello World
- 深入理解Java:类加载机制及反射
- 安卓海报轮播
- 数据结构中的七种排序算法介绍
- SpringMVC中的异常处理
- 【bzoj1010】玩具装箱toy 斜率优化dp
- 使用文件输出hello
- java之yield(),sleep(),wait()区别详解-备忘笔记
- hbase集群搭建
- JZOJ4893【NOIP2016提高A组集训第15场11.14】过河
- java8内置函数式接口
- PTA 4-3 二叉树的遍历
- web服务端和游戏服务端的区别
- 一道简单的推理题(日本某地发生了一件谋杀案,警察通过排查确定杀人凶手必为4个嫌疑犯的一个)
- 第四课(MySQL基础知识)