40 lines
822 B
C
40 lines
822 B
C
#include<stdio.h>
|
|
#include<stdlib.h>
|
|
#include<fcntl.h>
|
|
#include<unistd.h>
|
|
#include<string.h>
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
int fird,ent,ents;
|
|
off_t i;
|
|
char tst[256];
|
|
size_t n=1,m=1;
|
|
memset(tst,0,256);
|
|
|
|
if(argc!=3){
|
|
printf("erreur : %s <Nom Fichier> <offset>\n",argv[0]);
|
|
exit(-1);
|
|
}
|
|
|
|
fird=open(argv[1],O_CREAT|O_RDONLY,0600);
|
|
if(fird==-1){
|
|
perror("On ne peut pas ouvrir cela en O_WRONLY");
|
|
exit(1);
|
|
}
|
|
|
|
ent = strtol(argv[2],NULL,10);
|
|
|
|
lseek(fird,ent*4,SEEK_SET);
|
|
i=read(fird,&ents,4);
|
|
if(i==0){
|
|
printf("Offset is out of range!\n");
|
|
exit(1);
|
|
}
|
|
printf("The number at offset %d is 0x%08x --> %d\n",ent,ents,ents);
|
|
|
|
close(fird);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|