#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <Windows.h>
__int64 first;
__int64 end;
unsigned int c_Conversion_number(char *HeadPoint,char *NodePoint,int size);
int cString_extraction(char * Data, unsigned int ** pString);
int main()
{
char cString[1000];
int nData=0;
unsigned int *nPointdata=0;
printf("string input : ");
gets(cString);
first = __rdtsc();
nData = cString_extraction(cString,&nPointdata);
end = __rdtsc();
if(nData==0)
{
printf("No Data\n");
return 0;
}
while(*nPointdata != 0)
{
printf("정수 값 출력 : %d\n",(*nPointdata));
nPointdata++;
}
printf("Time:%d\n",end-first);
}
unsigned int c_Conversion_number(char *HeadPoint,char *NodePoint,int size)
{
unsigned int Data=0,realData=0;
for(;HeadPoint<NodePoint;HeadPoint++)
{
Data=(unsigned int)pow((long double)10,size--);
Data=Data*(*HeadPoint-'0');
realData+=Data;
}
return realData;
}
int cString_extraction(char * Data, unsigned int ** pString)
{
int m_size = 0,choise = 0,cs_Byte=0,nCount=0,nData=0,goto_Data=0;
char *HeadPoint = 0;
unsigned int *NodePoint=0;
m_size = sizeof(m_size);
for(;*Data != NULL;Data++)
{
if((*Data-'0')>=0 && (*Data-'0')<=9 && choise == 0)
{
choise = 1;
nCount++;
HeadPoint = Data;
}
else if(((*Data-'0')<0 || (*Data-'0')>9)&& choise == 1)
{
real_Back:
choise = 0;
cs_Byte = Data - HeadPoint;
*pString=(unsigned int *)realloc(*pString,(m_size*nCount));
NodePoint=*pString;
NodePoint=(NodePoint+(nCount-1));
*NodePoint=c_Conversion_number(HeadPoint,Data,cs_Byte-1);
if(goto_Data==1) break;
}
}
if(choise == 1)
{
goto_Data=1;
goto real_Back;
}
*pString=(unsigned int *)realloc(*pString,(m_size*nCount+1));
NodePoint=*pString;
NodePoint=NodePoint+nCount;
*NodePoint=0;
if(nCount==0) return 0;
return nCount;
}
'Soft Ware > C 언어!!' 카테고리의 다른 글
int main(int argc, char *argv[]) 에 대해서 (0) | 2011.12.12 |
---|---|
realloc 의 의미와 사용방법 (1) | 2011.12.02 |
ctime 함수 (0) | 2011.11.14 |
Time 함수와 time_t라는 변수에 대해서 (0) | 2011.11.14 |
strdup 함수 헤더파일은 string.h (0) | 2011.11.14 |