Today's work encounters a string that is either a double character string and a flag that has several int types in the decimal point of the numeric string
For example: "23.123"---"23123" + 3 is relatively simple. is to put the code here, later used, can be directly dragged to use
#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
#include <string>
void GetInfo (const char* pnum)
{
if (strlen (pnum) = = 0)
{
Return
}
Char num[100]={0};
int index = 0;
int decemal = 0;
BOOL Bisdecemal = false;
The variable string is not stored if it is found. But decimal starts counting.
for (int i = 0; Pnum[i]! = ' + '; i++)
{
if (pnum[i] = = '. ')
{
Bisdecemal = true;
Continue
}
Num[index] = Pnum[i];
index++;
if (bisdecemal)
{
decemal++;
}
}
std::cout<<num<< "----" <<decemal<<std::endl;
}
int _tmain (int argc, _tchar* argv[])
{
std::string num = "12.232"; The format of the target 12.232--"12232+3"
GetInfo (Num.c_str ());
GetChar ();
return 0;
}
The double type string is converted to a pure numeric string and a C + + code with a decimal point number