// changeNum.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string>
#include <vector>
bool GetNum(char* pStr_, double* pValue_)
{
size_t _nLong = strlen(pStr_);
if (!_nLong)
return true;
std::vector <double> *_pValue=(std::vector <double>*)pValue_;
for(char* _p = pStr_; _p < _p + _nLong; ++_p)
{
double _nValue = atof(_p);
_pValue->push_back(_nValue);
_p=strchr(_p,',');
if (_p == NULL)
break;
}
return true;
}
int _tmain(int argc, _TCHAR* argv[])
{
char _szStr[]="1.2,2.88,3,4,5,6";
std::vector <double> _vectorValue;
GetNum(_szStr, (double*)&_vectorValue);
//你想得到的所有的数字全在_vectorValue里边存着了
return 0;
}
//
#include "stdafx.h"
#include <string>
#include <vector>
bool GetNum(char* pStr_, double* pValue_)
{
size_t _nLong = strlen(pStr_);
if (!_nLong)
return true;
std::vector <double> *_pValue=(std::vector <double>*)pValue_;
for(char* _p = pStr_; _p < _p + _nLong; ++_p)
{
double _nValue = atof(_p);
_pValue->push_back(_nValue);
_p=strchr(_p,',');
if (_p == NULL)
break;
}
return true;
}
int _tmain(int argc, _TCHAR* argv[])
{
char _szStr[]="1.2,2.88,3,4,5,6";
std::vector <double> _vectorValue;
GetNum(_szStr, (double*)&_vectorValue);
//你想得到的所有的数字全在_vectorValue里边存着了
return 0;
}