diff --git a/SCR1.2/TP11/get_numb.c b/SCR1.2/TP11/get_numb.c new file mode 100644 index 0000000..c934ac4 --- /dev/null +++ b/SCR1.2/TP11/get_numb.c @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> + +#define SZBUF 256 + +int main(int argc, char const *argv[]){ + int fd,n,l,x; + long int i, offset; + if (argc<3){ + fprintf(stderr,"Usage : %s <file_name> <offset> \r",argv[0]); + exit (1); + } fd=open (argv[1], O_RDONLY); + if (fd==-1){ + perror("Opening destination file fails"); + exit (2); + } i=strtol(argv[2],NULL,0); + offset=i*(sizeof(int)); + l=lseek(fd,offset,SEEK_SET); + if(l==1){ + perror("lsink failed"); + close(fd); + exit (3); + } + n=read(fd,&x,sizeof(int)); + if(n==-1){ + perror("Read in file failed"); + close(fd); + exit (4); + } if(n==0){ + printf("Out of range\n"); + } else{ + printf("The number at offset %ld is 0x%08x --> %d \n",i,x,x); + } close(fd); + exit(0); +} \ No newline at end of file diff --git a/SCR1.2/TP11/put_numb.c b/SCR1.2/TP11/put_numb.c new file mode 100644 index 0000000..7b7c0a4 --- /dev/null +++ b/SCR1.2/TP11/put_numb.c @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <fcntl.h> + +#define SZBUF 256 + +int main(int argc, char const *argv[]){ + char buf[SZBUF]; + int fd,n,m; + if (argc<4){ + fprintf(stderr,"Usage : %s <file_name> <32-bit int in Hex> <Offset in Hex> \r",argv[0]); + exit (1); + } +} \ No newline at end of file diff --git a/SCR1.2/TP11/resultat.txt b/SCR1.2/TP11/resultat.txt index 6563d85..9d6a7c6 100644 Binary files a/SCR1.2/TP11/resultat.txt and b/SCR1.2/TP11/resultat.txt differ diff --git a/SCR1.2/TP11/store_numb.c b/SCR1.2/TP11/store_numb.c index ae5a9f9..3e7b404 100644 --- a/SCR1.2/TP11/store_numb.c +++ b/SCR1.2/TP11/store_numb.c @@ -9,7 +9,7 @@ int main(int argc, char const *argv[]){ char buf[SZBUF]; int fd,n,m; if (argc<2){ - fprintf(stderr,"Usage : %s <bSR_FILE> \r",argv[0]); + fprintf(stderr,"Usage : %s <SR_FILE> \n",argv[0]); exit (1); } fd=open (argv[1], O_WRONLY|O_TRUNC|O_CREAT,0b00); if (fd==-1){ diff --git a/SCR1.2/TP14/ft-file.dat b/SCR1.2/TP14/ft-file.dat new file mode 100644 index 0000000..9b61edb Binary files /dev/null and b/SCR1.2/TP14/ft-file.dat differ diff --git a/SCR1.2/TP15/reponses.txt b/SCR1.2/TP15/reponses.txt new file mode 100644 index 0000000..e69de29