12 Janvier
This commit is contained in:
parent
409b95d7d0
commit
7566b70d78
31
SCR1.2/TP11/copy.c
Executable file
31
SCR1.2/TP11/copy.c
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#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 <SRC_FILE><bSR_FILE> \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);
|
||||||
|
}
|
BIN
SCR1.2/TP11/resultat.txt
Normal file
BIN
SCR1.2/TP11/resultat.txt
Normal file
Binary file not shown.
31
SCR1.2/TP11/store_nb_rep.c
Normal file
31
SCR1.2/TP11/store_nb_rep.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#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 <bSR_FILE> \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);
|
||||||
|
}
|
27
SCR1.2/TP11/store_numb.c
Normal file
27
SCR1.2/TP11/store_numb.c
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.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<2){
|
||||||
|
fprintf(stderr,"Usage : %s <bSR_FILE> \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);
|
||||||
|
}
|
0
SCR1.2/TP12/DIR/37.187.104.44
Normal file
0
SCR1.2/TP12/DIR/37.187.104.44
Normal file
0
SCR1.2/TP12/DIR/37.187.107.140
Normal file
0
SCR1.2/TP12/DIR/37.187.107.140
Normal file
0
SCR1.2/TP12/DIR/37.187.109.209
Normal file
0
SCR1.2/TP12/DIR/37.187.109.209
Normal file
0
SCR1.2/TP12/DIR/5.135.162.217
Normal file
0
SCR1.2/TP12/DIR/5.135.162.217
Normal file
0
SCR1.2/TP12/DIR/5.196.160.139
Normal file
0
SCR1.2/TP12/DIR/5.196.160.139
Normal file
0
SCR1.2/TP12/DIR/62.210.28.176
Normal file
0
SCR1.2/TP12/DIR/62.210.28.176
Normal file
0
SCR1.2/TP12/DIR/91.224.149.41
Normal file
0
SCR1.2/TP12/DIR/91.224.149.41
Normal file
0
SCR1.2/TP12/DIR/94.23.32.122
Normal file
0
SCR1.2/TP12/DIR/94.23.32.122
Normal file
Loading…
Reference in New Issue
Block a user