C++string类使用、定义
line[a]p1[m];
}
strcat(line,p2);
cout<
}
void string::index(char *n)
{
char *p;
char n1[100];
char n2[100];
strcpy(n1,line);
strcpy(n2,n);
pstrstr(n1,n2);
int l;
lstrlen(n1);
cout<<"The words you want to find is:"<
if(p)
{
strcpy(n2,p);
for(int i0;i
{
if(n1[i]n2[0])
{
cout<
}
}
void string::replace(char *q,char *p)//q被替换串,考试,大提示p替换串
{
char p1[100];
char p2[100];
char p3[100];
strcpy(p1,line);
strcpy(p2,p);
strcpy(p3,q);
pstrstr(p1,p3);
if(p)
{
int i,j;
int lpstrlen(p);
int lp1strlen(p1);
int lp2strlen(p2);
int lp3strlen(p3);
cout<<"The sourse string is : "<
void string::strempty()
{
int istrlen(line);
if(i0)
{
cout<<"The string is empty !";
}
else
{
cout<<"The string is not empty !";
}
}
string string::operator (string s1)
{
strcpy(line,s1.line);
return *this;
}
string string::operator + (string s1)
{
strcat(line,s1.line);
return *this;
}
void string::operator < (string s1)
{
int lstrlen(s1.line);
int mstrlen(line);
if(m
{
cout<<"less and equal";
}
else
{
cout<<"not less and equal";
}
}
void string::operator ! (string s1)
{
char n1[100];
strcpy(n1,s1.line);
int l;
lstrlen(line);
int m;
mstrlen(n1);
if(l!m)
