2

I've tried to convert string to double using atof function. double strtod (const char* str, char** endptr). It works fine, but why is endptr non-const? **endptr always points to *endptr and not to endptr.

Ryan Haining
  • 35,360
  • 15
  • 114
  • 174
Narek Atayan
  • 1,479
  • 13
  • 27
  • To clarify, are you asking, why the parameter isn't a pointer to non-const pointer to const char? – hyde Feb 13 '15 at 21:43
  • I have something like this. void foo(const std::string& str) { ..... const end = str.c_str(); const double d = strtod(end, &end); //compile error } I don't want use const_cast. – Narek Atayan Feb 13 '15 at 21:52

0 Answers0