Use int and char in pipes in c

1

Can whole numbers (int) and characters (char) be transmitted for the same pipe or do you need to create two different pipes? How would it be?

    
asked by minicaza 14.01.2018 в 11:45
source

1 answer

1

For an integer it would be something like this:

int n = 45;
write(pipe, &n, sizeof(n));

And for a string of characters like this:

const char* cad = "una prueba";
write(pipe, cad, strlen(cad) + 1);
    
answered by 16.01.2018 / 12:02
source