我写的C++的函数,你修改一下
/*
Description: this function is Parse Strings use Delimiter,Delimiter default
is "$"
function: ParseStrings
parameter:
List : Parse Strings array
strSource: string source
Delimiter: Parse character
return :bool,Parse success is true ,else false
*/
bool __fastcall TfrmMain:
arseStrings(TStringList * List,AnsiString strSource,
AnsiString Delimiter="$")
{
//分割用 Delimiter (默认是$)分开的字符串,并将分开的字符串保存到数组List中
if((List==NULL)||strSource.Length()<1) return false;
List->Clear();
int iEnd=0,iLength=0;
iLength=strSource.Length();
AnsiString strTemp;
iEnd=strSource.Pos(Delimiter);
if(iEnd>0)
{
do
{
iEnd=strSource.Pos(Delimiter);
if(iEnd>0)
{
strTemp=strSource.SubString(1,iEnd-1);
List->Add(strTemp);
strSource=strSource.SubString(iEnd+1,iLength-iEnd);
}
else
{
if(strSource.Length()>0)
List->Add(strSource);
}
}
while(iEnd!=0);
}
else
{
if(strSource.Length()>0)
List->Add(strSource);
}
return true;
}
//---------------------------------------------------------------------------