From 7566b70d78ce64b4a5579c051d7739a62bb77712 Mon Sep 17 00:00:00 2001 From: pourchot Date: Thu, 12 Jan 2023 10:57:33 +0100 Subject: [PATCH] 12 Janvier --- SCR1.2/TP11/copy.c | 31 +++++++++++++++++++++++++++++++ SCR1.2/TP11/resultat.txt | Bin 0 -> 32 bytes SCR1.2/TP11/store_nb_rep.c | 31 +++++++++++++++++++++++++++++++ SCR1.2/TP11/store_numb.c | 27 +++++++++++++++++++++++++++ SCR1.2/TP12/DIR/37.187.104.44 | 0 SCR1.2/TP12/DIR/37.187.107.140 | 0 SCR1.2/TP12/DIR/37.187.109.209 | 0 SCR1.2/TP12/DIR/5.135.162.217 | 0 SCR1.2/TP12/DIR/5.196.160.139 | 0 SCR1.2/TP12/DIR/62.210.28.176 | 0 SCR1.2/TP12/DIR/91.224.149.41 | 0 SCR1.2/TP12/DIR/94.23.32.122 | 0 12 files changed, 89 insertions(+) create mode 100755 SCR1.2/TP11/copy.c create mode 100644 SCR1.2/TP11/resultat.txt create mode 100644 SCR1.2/TP11/store_nb_rep.c create mode 100644 SCR1.2/TP11/store_numb.c create mode 100644 SCR1.2/TP12/DIR/37.187.104.44 create mode 100644 SCR1.2/TP12/DIR/37.187.107.140 create mode 100644 SCR1.2/TP12/DIR/37.187.109.209 create mode 100644 SCR1.2/TP12/DIR/5.135.162.217 create mode 100644 SCR1.2/TP12/DIR/5.196.160.139 create mode 100644 SCR1.2/TP12/DIR/62.210.28.176 create mode 100644 SCR1.2/TP12/DIR/91.224.149.41 create mode 100644 SCR1.2/TP12/DIR/94.23.32.122 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 0000000000000000000000000000000000000000..6563d8550ecc0ad0a6eb677610845294bbf45f8b GIT binary patch literal 32 ecmZQ&U|?VbVp$;m_y7NYCLj$0zkqCUAPoR#a0o8| literal 0 HcmV?d00001 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