46 lines
864 B
C
46 lines
864 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;
|
|
short int i;
|
|
off_t l;
|
|
char tst[256];
|
|
size_t n=1,m=1;
|
|
memset(tst,0,256);
|
|
|
|
if(argc!=4){
|
|
printf("erreur : %s <file_name> <32-bit int in Hex> <Offset in Hex>\n",argv[0]);
|
|
exit(-1);
|
|
}
|
|
|
|
fird=open(argv[1],O_CREAT|O_WRONLY,0600);
|
|
if(fird==-1){
|
|
perror("On ne peut pas ouvrir cela en O_RDONLY");
|
|
exit(1);
|
|
}
|
|
|
|
ent = strtol(argv[3],NULL,16);
|
|
|
|
l=lseek(fird,ent*4,SEEK_SET);
|
|
printf("%ld\n",l);
|
|
|
|
if(l==-1){
|
|
perror("erreur dans lseek");
|
|
exit(2);
|
|
}
|
|
|
|
|
|
ents = strtol(argv[2],NULL,16);
|
|
|
|
write(fird,&ents,4);
|
|
|
|
close(fird);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|