ajout code

This commit is contained in:
2026-04-16 18:56:01 +02:00
parent 96b130ecfa
commit 588d27633b
3 changed files with 78 additions and 10 deletions
+15 -10
View File
@@ -14,14 +14,20 @@ ___( o)>
Coic Coic
*/
void clc(int n){
void clc(){
int n = 0;
int pipe1[2];
int pipe2[2];
int pipe2[2];
char buffer[2048];
if(pipe(pipe2) == -1) return;
if(pipe(pipe1) == -1) return;
fgets(buffer, 2047, stdin);
n = atoi(buffer);
pipe1[1] = n;
pid_t pid = fork();
if(pid < 0) return;
@@ -31,19 +37,16 @@ void clc(int n){
while(1){
if(pipe1[0] != NULL) pipe2[1] = n* n;
if(pipe1[0]){
pipe2[1] = n* n;
exit(0);
}
}
}
//Teacher ? WTF what are you doing with my uncle ? Why do you have an eggplant in your right hand and a riding whip in your left hand ? WTF is going on here
else {
char buffer[2048];
fgets(buffer, 2047, stdin);
int n = 0;
n = atoi(buffer);
if(n == -1) {
close(pipe1[0]);
close(pipe2[1]);
@@ -53,13 +56,15 @@ void clc(int n){
wait(NULL); //on attends le Child
printf("The Oracle says the square is: %i", pipe2[0]);
printf("The Oracle says the square is: %i\n", pipe2[0]);
}
}
int main() {
clc();
/*
//[0] -> lecture | [1]-> ecriture
int pipe1[2];