C: convert argv[1] to double

Viewed 12591

I need to pass a double to my program, but the following does not work:

int main(int argc, char *argv[]) {

double ddd;

ddd=atof(argv[1]);

printf("%f\n", ddd);

return 0;
}

If I run my program as ./myprog 3.14 it still prints 0.000000.

Can somebody please help?

3 Answers
Related