13,825
社区成员
发帖
与我相关
我的任务
分享
void __fastcall TForm1::Button1Click(TObject *Sender)
{
AnsiString a,b,str;
a = "Hello,world";
b = "wor"; //"word"
str = a + " contains " + b ;
for(int i=0;i<b.Length();i++)
{
int t = a.Pos(b.SubString(i+1,1));
if(t<=0)
{
str = a + " doesn't contain " + b ;
break ;
}
}
ShowMessage(str);
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
AnsiString a,b;
a="Hello,world";
b="wor"; //"word"
int Pos=a.Pos(b); //为了兼容Delphi,下标从1开始
ShowMessage(IntToStr(Pos));
if(Pos>0)
ShowMessage(a+" contains "+b);
else
ShowMessage(a+" doesn't contain "+b);
char *sub=strstr(a.c_str(),b.c_str());
ShowMessage(AnsiString(sub));
if(sub)
ShowMessage(a+" contains "+b);
else
ShowMessage(a+" doesn't contain "+b);
}