c_cpp 在const char **中使用strtod

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 在const char **中使用strtod相关的知识,希望对你有一定的参考价值。

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

// Used strtod to extract number from string.

int num_is_int(double d)
{
  return d == floor(d);
}


int main(void)
{
  const char* tester = "1234-> out";
  char** moved; // This is used to store the new location of string.
  double result = strtod(tester, moved);
  printf("The result is %f,\n the moved string is %s\n", result, *moved);
  printf("Result is also int %d\n", num_is_int(result));
  return 0;
}

以上是关于c_cpp 在const char **中使用strtod的主要内容,如果未能解决你的问题,请参考以下文章