Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
468 B
2
Indexable
Never
#include <unistd.h>
#include <iostream>

using namespace std;

int main() {

    int p[2] = {0};
    //p[0] for reading
    //p[1] for writing

    pipe(p);
    int n = fork();
    if (n == 0) {
        int b;
        int j = read(p[0], &b, sizeof(b));
        cout << "(FILS) : b = " << b << ". j = " << j << endl; 
    }  
    else {
        int i = 3001;
        int i_sz = sizeof(i);
        write(p[1], &i, i_sz);
    }


    return 0;
}