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]);
}

Recommended Answers

All 2 Replies

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));

Thanks a lot it works now

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.