代码拉取完成,页面将自动刷新
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#define LENGTH 16
/**
* 仿照linux命令: od -tx1 -tc 文件地址
* 传入文件地址
*/
void myod(char *address)
{
int fd;
int line_count=0;
int sum_count=0;
int i=0;
char ch[LENGTH];
if((fd=open(address, O_RDONLY))==-1)
{
perror(address);
exit(1);
}
while((line_count=read(fd, ch, sizeof(char)*16))>0)
{
sum_count += line_count; //开头的八进制表示
printf("%07o ", sum_count);
for(i=0; i<LENGTH; i++) //第一行,二进制表示
{
printf("%-4d", ch[i]);
}
printf("\n ");
for(i=0; i<LENGTH; i++) //第二行,对应的字符
{
if(ch[i]=='\n') printf("\\n "); //将'\n'输出至屏幕
else printf("%-4c", ch[i]);
}
printf("\n");
}
close(fd);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。