0

hi everyone, i'm trying to do a program in c, GCC UNIX and i have this error: warning: passing argument 2 of write makes pointer from integer without a cast
i try to use TUBE, communication between process and i use write(fd[1],2,1); but it gives this error please i nead a help, this is the code:

pid1=fork();
if (pid1>0)
    {
    printf("chui pereeeeeeeee n %d\n",getpid());
close(fd[1]);
int val;
do
{
read(fd[0],&val,1);
printf("%d",val);
}
while(val!=0);
close(fd[0]);

    }
else
    {
    printf("chui fils createur n %d\n",getpid());
close(fd[0]);

for(i=deb;i<=n;i++) {printf("%d ",t[i]);}
printf("\n\n");
printf("%d\n",n);
deb=6;
n=premier(t,deb,n);

for(i=deb;i<=n;i++) {write(fd[1],t[i],1);}
write(fd[1],0,1);
close(fd[1]);
}

Edited by mike_2000_17: Fixed formatting

2
Contributors
2
Replies
6
Views
6 Years
Discussion Span
Last Post by medamineb
0

First question. What is t[] an array of, characters? I ask because you pass 1 as the size in your write function.

Second question...You have

int val;
read(fd[0],&val,1);

val is an integer...its size should be sizeof(int)...e.g.

read(fd[0], &val, sizeof(int));

Third question...Well more of a pointer

write(fd[1],t,1);

should be

write(fd[1],&t,sizeof(whatever t is));

Edited by gerard4143: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.