Help with function
Walter Bright
bright at Data-IO.COM
Tue Jan 9 07:03:43 AEST 1990
In article <3198 at cbnewsj.ATT.COM> veenu at cbnewsj.ATT.COM (veenu.r.rashid) writes:
< On the compiler I'm using, abs() and strtol() seem to generate incorrect
<or at least inaccurate results. I'm using the following code:
<main(int argc, char *argv[])
<{ double temp;
< temp = strtod(argv[1]); /* get the argument as a double */
< printf("Absolute value of %g is %g\n", temp, abs(temp));
<}
Errors:
You need the double abs which is called fabs().
You need to #include:
#include <stdio.h> /* for printf */
#include <math.h> /* for fabs */
#include <stdlib.h> /* for strtod */
More information about the Comp.lang.c
mailing list