'Passing more than one int between processes via pipe
I'm new to C. My question is more related to syntax. I know how to use pipe to send integer over the pipe.
writing to the pipe
int n = 50;
write(fd[1], &n, sizeof(n));
reading from the pipe
int n;
read(fd[0], &n, sizeof(n));
But I want to know how do i modify the pipe to send 2 integers? I tried the code below but it didn't work.
writing to the pipe
int n1 = 50, n2 = 30;
write(fd[1], &n1 &n2, sizeof(n1)+sizeof(n2));
reading from the pipe
int n1, n2;
read(fd[0], &n1 &n2, sizeof(n1)+sizeof(n2));
Thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
