2010년/시스템제어
저수준 입출력 숙제
뽀얀햄스터
2010. 5. 11. 21:24
#include<stdio.h>
#include<fcntl.h>
#include<sys\types.h>
#include<sys\stat.h>
int main()
{
int fd;
int bytes;
int i;
char buf[512];
if((fd=open("main.in",O_RDONLY|O_BINARY))<0)
{
printf("main.in을 열수없습니다 \n");
return 0;
}
while((bytes=read(fd,buf,512))>0)
{
for(i=0;i<bytes;i++)
{
printf("%x",buf[i]);
if(i%2==1)
{
printf("\t");
}
}
}
close(fd);
return 0;
}