1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| struct rsplit
{ int index;
char* str;
};
rsplit asplit(const char* str,int index,char* car = "/")
{ char* m_str = new char;
int Counter=0;
bool truecar = false;
int CountCar;
while (*(str + index)!='\0')
{
CountCar = 0;
while((*(car+CountCar)!='\0')&&(truecar==false))
{
if (*(str + index)==*(car+CountCar))
truecar=true;
CountCar++;
}
if(truecar==true)
{ *(m_str +Counter)='\0';
rsplit m_split;
m_split.index = index;
m_split.str = m_str;
return m_split;
}
else
{
*(m_str + Counter)=*(str +index);
index++;
Counter++;
}
}
*(m_str +Counter)='\0';
rsplit m_split;
m_split.index = index;
m_split.str = m_str;
return m_split;
}
extern "C" __declspec(dllexport) char** __stdcall split(const char* str,char* car = "/")
{ int index=0;int count=0;rsplit m_split;
char** Test=new char*;int lenstr=strlen(str);
while (index<lenstr)
{
m_split= asplit(str,index,car);
Test[count]=m_split.str;
index=m_split.index +1;
count++;
}
Test[count]=NULL;
return Test;
} |
Partager