M
merrittr
Hi all,
i am struggling with c strings still here is what i want, pass in 2
string vals convert them to doubles add them
then convert the result back to a char string and return it to a
printf statement.
can you see where I am going wrong?
printf("%s\n",add("d","3","4"));
char *add(char ctype, char *i, char *j)
{
double x,y,z;
char retval[10];
printf("%s %s %s\n",retval,i,j);
z = atof(i)+atof(j);
sprintf( retval, "%i",z );
printf("%s %d %d\n",retval,atof(i),atof(j));
return retval;
}
i am struggling with c strings still here is what i want, pass in 2
string vals convert them to doubles add them
then convert the result back to a char string and return it to a
printf statement.
can you see where I am going wrong?
printf("%s\n",add("d","3","4"));
char *add(char ctype, char *i, char *j)
{
double x,y,z;
char retval[10];
printf("%s %s %s\n",retval,i,j);
z = atof(i)+atof(j);
sprintf( retval, "%i",z );
printf("%s %d %d\n",retval,atof(i),atof(j));
return retval;
}