Developpement/23SCR/SCR011/store_nb_rep.c

39 lines
639 B
C

#include<stdio.h>
#include<fcntl.h>
#include<unistd.h>
#include<stdlib.h>
#include <string.h>
#define szbuf 256
int main(int argc, char const *argv[])
{
char buf[szbuf];
int fd,x;
off-t l;
unsigned int x;
long int i, offset;
if(argc<4)
{
fprintf(stderr, "Usage: %s ./get_numb <file_name> <offset>",argv[1]);
exit(1);
}
fd = open(argv[1],O_RDONLY);
if(fd == -1)
{
perror("Opening file fails");
exit(2);
}
x = (unsigned int) strtol(argv[2],NULL,16);
i = (unsigned int) strtol(argv[3],NULL,16);
offset = i x sizeof(int);
l = lseek(fd,0,SEEK_SET);
if(l == -1)
{
close(fd);
exit(3);
}
close(a);
exit(0);
}