لدي برنامج بلغة c under linux ubuntu لكن به مشكلة انه يعطي ناتج جمع المصفوفات كل واحدة على حدة اريده ان يعطيني ناتج جمعهم يعني اريد ان يعطيني ناتج 6+13+13
#include <stdio.h>
#include <sys/shm.h>
#include <sys/ipc.h>
void main()
{
char c[128];
int i,j , she,total;
int result=0;
int pd[2];
int m[3][3]={{1,2,3},{0 , 5 ,8},{4 , 7 ,2}};
pipe(pd);
int pid=fork();
if (pid==0)
{
wait();
for (i=0; i<3; i++)
{
result = 0;
for( j=0; j<3; j++)
{
result+=m[j];
}
write(pd[1],result,sizeof(double));
printf("%d\n",result);
wait();
}
}
else
{
wait();
read(pd[0], result, sizeof(double)) ;
int result1=result;
wait();
read(pd[0], result, sizeof(double)) ;
int result2=result;
wait();
read(pd[0], result, sizeof(double)) ;
int result3=result;
total=result1+result2+result3;
printf("%d\n",total);
}
}