如何将任何数字(例如 822042461(字符串类型))转换为 822042461(双精度类型)?

How can I convert any numbers, for example 822042461 (string-type) to 822042461 (double-type)?

如何在 C++ 中将任何数字(例如 822042461(字符串类型))转换为 822042461(双精度类型)?非常感谢!

sscanf 可能有用:

/* sscanf example */
#include <stdio.h>

int main ()
{
  char sentence []="822042461";
  double i;

  sscanf (sentence,"%lf",&i);
  printf ("%lf\n",i);

  return 0;
}

$ gcc -o /tmp/test.exe  /tmp/test.cpp
$ /tmp/test.exe                      
822042461.000000