X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/d47d44b2ed067c834ef210ad544512e7581a1c8e..f4125505064e3ff346b31ab9e48f894672e5a7a7:/cost_func.cpp diff --git a/cost_func.cpp b/cost_func.cpp index bdea62e..c3a463b 100644 --- a/cost_func.cpp +++ b/cost_func.cpp @@ -5,21 +5,21 @@ #include #include "cost_func.h" -cost_func::cost_func(const char *param) +cost_func::cost_func(const char* param) { int len = strlen(param); char tmpbuf[len + 1]; - char *tmp = tmpbuf; + char* tmp = tmpbuf; memcpy(tmp, param, len + 1); degree = std::count(tmp, tmp + len, ','); factor = new double[degree + 1]; for (int i = degree ; i > 0 ; i--) { - char *next = strchr(tmp, ','); + char* next = strchr(tmp, ','); *next++ = '\0'; - factor[i] = atof(tmp); + std::istringstream(tmp) >> factor[i]; tmp = next; } - factor[0] = atof(tmp); + std::istringstream(tmp) >> factor[0]; } cost_func::~cost_func()