1 Star 0 Fork 0

Besti 20155338/Linux 20155338

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
csjmyod.c 964 Bytes
一键复制 编辑 原始数据 按行查看 历史
Besti 20155338 提交于 8年前 . MyOD.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#define M 100
void tx(int fd);
void tc(int fd);
int main(int argc,char *argv[])
{
int fd;
if((fd=open(argv[1],O_RDONLY,0))==-1)
printf("无法读取该文件\n");
else
{
tc(fd);
close(fd);
fd=open(argv[1],O_RDONLY,0);
tx(fd);
close(fd);
}
}
void tc(int fd)
{
int i, a;
char ch[M];
printf("原文件输出为:\n");
while((a=read(fd,ch,16))!=0){
for(i=0;i<a;i++)
{
if(ch[i]=='\n')
printf(" \\n");
else
printf("%4c",ch[i]);
}
printf("\n");
}
}
void tx(int fd)
{
int i, a;
char ch[M];
printf("16进制输出为:\n");
while((a=read(fd,ch,16))!=0){
for(i=0;i<a;i++)
{
if(ch[i]=='\n')
printf(" 0a");
else
printf("%4x",ch[i]);
}
printf("\n");
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Csj996/Besti.git
git@gitee.com:Csj996/Besti.git
Csj996
Besti
Linux 20155338
master

搜索帮助