I need your help Just want to convert a cstring like this one 128,140
to int number 128140
I use this function but it fills number with 128 only.
_stscanf(text, _T("%d"), &number);
any ideas ?? Thank you :)
I designed for you this simple function. You can use it as reference code for more complex issue. Following a complete example:
#include <stdio.h>
#include <string>
#include <ctype.h>
using namespace std;
long StingToNumber(string AString)
{
string LStrNum;
for(int i=0; i < AString.size(); ++i)
if( isdigit(AString[i]) )
LStrNum += AString[i];
return atoi(LStrNum.c_str());
}
int _tmain(int argc, _TCHAR* argv[])
{
string LString = "128,140";
long LNum = StingToNumber("128,140");
printf("String %s to number %d", LString.c_str(), LNum);
return 0;
}
If my solution help you, please remember to check it as answered.
Ciao (from Italy) Angelo
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다