akhy laisse le git

This commit is contained in:
Vieira Enzo 2022-01-25 12:47:42 +01:00
parent 7a9c24b042
commit 6d9aa077b1
8 changed files with 145 additions and 30 deletions

View File

@ -0,0 +1,6 @@
zebi2
zebi2

View File

@ -0,0 +1,39 @@
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
#include<string.h>
int main(int argc, char* argv[]) {
int fird,ent,ents;
off_t i;
char tst[256];
size_t n=1,m=1;
memset(tst,0,256);
if(argc!=3){
printf("erreur : %s <Nom Fichier> <offset>\n",argv[0]);
exit(-1);
}
fird=open(argv[1],O_CREAT|O_RDONLY,0600);
if(fird==-1){
perror("On ne peut pas ouvrir cela en O_WRONLY");
exit(1);
}
ent = strtol(argv[2],NULL,10);
lseek(fird,ent*4,SEEK_SET);
i=read(fird,&ents,4);
if(i==0){
printf("Offset is out of range!\n");
exit(1);
}
printf("The number at offset %d is 0x%08x --> %d\n",ent,ents,ents);
close(fird);
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,5 @@
5
8
6
4
8

View File

@ -0,0 +1,45 @@
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
#include<string.h>
int main(int argc, char* argv[]) {
int fird,ent,ents;
short int i;
off_t l;
char tst[256];
size_t n=1,m=1;
memset(tst,0,256);
if(argc!=4){
printf("erreur : %s <file_name> <32-bit int in Hex> <Offset in Hex>\n",argv[0]);
exit(-1);
}
fird=open(argv[1],O_CREAT|O_WRONLY,0600);
if(fird==-1){
perror("On ne peut pas ouvrir cela en O_RDONLY");
exit(1);
}
ent = strtol(argv[3],NULL,16);
l=lseek(fird,ent*4,SEEK_SET);
printf("%ld\n",l);
if(l==-1){
perror("erreur dans lseek");
exit(2);
}
ents = strtol(argv[2],NULL,16);
write(fird,&ents,4);
close(fird);
return EXIT_SUCCESS;
}

View File

@ -1,29 +0,0 @@
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#define BUFSIZE 256
int main(int argc, char * argv[]){
int r,x,f,y,n;
char buf[BUFSIZE];
if(argc<2){
fprintf(stdin,"Usage: %s <file>\n",argv[0]);
exit(1);
}
f=open(argv[1],O_WRONLY|O_CREAT|O_TRUNC,0600);
if(f==-1){
perror("Opening file failed !");
exit(2);
}
write(1,"Numb --> ",9);
while((n=read(0,buf,BUFSIZE))!=0){
r=write(f,buf,n);
if(r==-1){
perror("writing failed");
exit(3);
}
write(1,"Numb --> ",9);
}
close(f);
exit(0);
}

BIN
APL1.2/SCR1.2/TP11/store_numb Executable file

Binary file not shown.

View File

@ -0,0 +1,29 @@
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#define BUFSIZE 256
int main(int argc, char * argv[]){
int r,x,f,y,n;
char buf[BUFSIZE];
if(argc<2){
fprintf(stdin,"Usage: %s <file>\n",argv[0]);
exit(1);
}
f=open(argv[1],O_WRONLY|O_CREAT|O_TRUNC,0600);
if(f==-1){
perror("Opening file failed !");
exit(2);
}
write(1,"Numb --> ",9);
while((n=read(0,buf,BUFSIZE))!=0){
r=write(f,buf,n);
if(r==-1){
perror("writing failed");
exit(3);
}
write(1,"Numb --> ",9);
}
close(f);
exit(0);
}

View File

@ -1 +1,21 @@
zebi
5
44
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4