In the first case if iam using the individual variable like below
Code:
void getSumDifAndProduct(int a,int b,int *sum,int *dif,int *product);
void getSumDifAndProduct(int a,int b,int *sum,int *dif,int *product)
{
*sum = a+b;
*dif = (a-b);
*product = (a*b);
}
int main()
{
int a=0,b=0,sum=0,dif=0,product=0;
printf("Please Enter the a and b values \n");
scanf("%d %d",&a,&b);
getSumDifAndProduct(a,b,&sum,&dif,&product);
printf("a and b is %d %d \n",a,b);
printf("a and b sum is %d \n",sum);
printf("a and b dif is %d \n",dif);
printf("a and b product is %d \n",product);
return 0;
}
i have to use the * before the variables .
else
sum = a+b;
i get error like below
ex1.c:7: warning: assignment makes pointer from integer without a cast
I understand here as we need to put the value in the memory location of sum .
But the structure variable should also be the same case .
Why should we avoid giving the * here .