Can someone explain to me why this bit of code works and the commented version of double functest doesnt. dont understand functions very well it seems...
insert
Code:
/*****START**/
#include<stdio.h>
#include<stdlib.h>
typedef struct
{
//
double test1;
double test2;
}t;
t tab;
t * q = &tab;
double functest(void);
int main()
{
//
printf("enter test1\t");
scanf("%lg",&q->test1);
printf("\nenter test2\t");
scanf("%lg",&q->test2);
/* printf("hence function returns %lg",functest(q->test1,q->test2));*/
printf("hence function returns %lg\n",functest());
return 0;
}
/*double functest(double q->test1,double q->test2)*/
/*{*/
/* return q->test1 * q->test2;*/
/*}*/
double functest(void)
{
double res;
res=q->test1*q->test2;
printf("answer is%lg",res);
return res;
}
/****END***/
How do you provide arguments to a function where the variable is in a struct???
Thanks for your help