diff --git a/SCR1.2/TP11/copy.c b/SCR1.2/TP11/copy.c new file mode 100755 index 0000000..12ab339 --- /dev/null +++ b/SCR1.2/TP11/copy.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include + +#define SZBUF 256 + +int main(int argc, char const *argv[]){ + char buf[SZBUF]; + int fs,fd,n,m; + if (argc<3){ + fprintf(stderr,"Usage : %s \r",argv[0]); + exit (1); + } fs=open (argv[1], O_RDONLY); + if (fs==-1){ + perror("Opening source file fails"); + exit(2); + } fd=open (argv[2], O_WRONLY|O_TRUNC|O_CREAT,0b00); + if (fd==-1){ + perror("Opening destination file fails"); + exit(3); + } while (n=read(fs,buf,SZBUF)){ + m=write(fd,buf,n); + if (m==-1){ + perror("Writing in file fails"); + exit(4); + } + } close(fs); + close(fd); + exit(0); +} \ No newline at end of file diff --git a/SCR1.2/TP11/resultat.txt b/SCR1.2/TP11/resultat.txt new file mode 100644 index 0000000..6563d85 Binary files /dev/null and b/SCR1.2/TP11/resultat.txt differ diff --git a/SCR1.2/TP11/store_nb_rep.c b/SCR1.2/TP11/store_nb_rep.c new file mode 100644 index 0000000..03c4d9c --- /dev/null +++ b/SCR1.2/TP11/store_nb_rep.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include + +#define SZBUF 256 + +int main(int argc, char const *argv[]){ + char buf[SZBUF]; + int fd,n,m,x; + if (argc<2){ + fprintf(stderr,"Usage : %s \r",argv[0]); + exit (1); + } fd=open (argv[1], O_WRONLY|O_TRUNC|O_CREAT,0b00); + if (fd==-1){ + perror("Opening destination file fails"); + exit(2); + } write (1,"Numb --> ",9); + memset(buf,0,SZBUF); + while (n=read(0,buf,SZBUF)){ + x=(int)strtol(buf,NULL,0); + m=write(fd,&x,sizeof(int)); + if (m==-1){ + perror("Writing in file fails"); + exit(3); + }memset(buf,0,SZBUF); + write (1,"Numb --> ",9); + } close(fd); + exit(0); +} \ No newline at end of file diff --git a/SCR1.2/TP11/store_numb.c b/SCR1.2/TP11/store_numb.c new file mode 100644 index 0000000..ae5a9f9 --- /dev/null +++ b/SCR1.2/TP11/store_numb.c @@ -0,0 +1,27 @@ +#include +#include +#include +#include + +#define SZBUF 256 + +int main(int argc, char const *argv[]){ + char buf[SZBUF]; + int fd,n,m; + if (argc<2){ + fprintf(stderr,"Usage : %s \r",argv[0]); + exit (1); + } fd=open (argv[1], O_WRONLY|O_TRUNC|O_CREAT,0b00); + if (fd==-1){ + perror("Opening destination file fails"); + exit(2); + } write (1,"Numb --> ",9); + while (n=read(0,buf,SZBUF)){ + m=write(fd,buf,n); + if (m==-1){ + perror("Writing in file fails"); + exit(3); + }write (1,"Numb --> ",9); + } close(fd); + exit(0); +} \ No newline at end of file diff --git a/SCR1.2/TP12/DIR/37.187.104.44 b/SCR1.2/TP12/DIR/37.187.104.44 new file mode 100644 index 0000000..e69de29 diff --git a/SCR1.2/TP12/DIR/37.187.107.140 b/SCR1.2/TP12/DIR/37.187.107.140 new file mode 100644 index 0000000..e69de29 diff --git a/SCR1.2/TP12/DIR/37.187.109.209 b/SCR1.2/TP12/DIR/37.187.109.209 new file mode 100644 index 0000000..e69de29 diff --git a/SCR1.2/TP12/DIR/5.135.162.217 b/SCR1.2/TP12/DIR/5.135.162.217 new file mode 100644 index 0000000..e69de29 diff --git a/SCR1.2/TP12/DIR/5.196.160.139 b/SCR1.2/TP12/DIR/5.196.160.139 new file mode 100644 index 0000000..e69de29 diff --git a/SCR1.2/TP12/DIR/62.210.28.176 b/SCR1.2/TP12/DIR/62.210.28.176 new file mode 100644 index 0000000..e69de29 diff --git a/SCR1.2/TP12/DIR/91.224.149.41 b/SCR1.2/TP12/DIR/91.224.149.41 new file mode 100644 index 0000000..e69de29 diff --git a/SCR1.2/TP12/DIR/94.23.32.122 b/SCR1.2/TP12/DIR/94.23.32.122 new file mode 100644 index 0000000..e69de29