the actual problem is not with the calcs it is with the atof function llok at this
Code:
int main(int argc, char *argv[])
{
double *converted=(double *)malloc(argc*sizeof(double));
float result=0.0;
char ch;
int ctr,i=0;
for ( i = 1; i < argc; i++ ) /* Skip program name */
{
converted[i - 1] = atof ( argv[i]);
printf("%lf",converted[i-1]);
}
ch=*argv[2];
calcs(ch,converted,&result);
print_result(result);
free(converted);
getchar();
return 0;
}
float calcs(char ch, double *argv,float *ptr)
{
switch(ch)
{
case'+': add(argv,&ptr);
break;
case'-': sub(argv,&ptr);
break;
case'*': mul(argv,&ptr);
break;
case'/': div(argv,&ptr);
break;
default: printf("Invalid Operation\n");
break;
}
}
and in tha mian atof will always return me the 0.0 rather than giving me the converted value of the string.
i can this code will let u know what is the problem is. and the rest of the part is working fine
thank u very much
s.s.harish