源代码:#include <stdio.h>
#define MaxSize 100
typedef struct //串结构体
{ char ch[MaxSize];
int length;
} SqString;
void StrAssign(SqString &s,char t[]) //串赋值
{
int i;
for(i=0;t[i]!=’\0’;i++)
s.ch[i]=t[i];
s.length=i;
}
int StrEqual(SqString s,SqString t)//判断串是否相等
{
int same=1,i;
if(s.length!=t.length)
{
same=0;
}
else{
for(i=0;i<s.length;i++)
if(s.ch[i]!=t.ch[i])
{
same=0;
break;
}
}
return(same);
}
int StrLength(SqString s)//计算串长度
{
return(s.length);
}
SqString Concat(SqString s,SqString t)//串连接
{
SqString str;
int i;
str.length=s.length+t.length;
for(i=0;i<s.length;i++)
str.ch[i]=s.ch[i