#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#define MaxSize 100
typedef struct
{
char data[MaxSize];
int length;
} SqString;
//串赋值
void StrAssign(SqString *s, char cstr[])
{
int i;
for (i=0; cstr[i]!='\0'; i++)
(*s).data[i]=cstr[i];
(*s).length=i;
}
//串复制
void StrCopy(SqString *s,SqString t)
{
int i;
for (i=0; i<t.length; i++)
(*s).data[i]=t.data[i];
(*s).length=t.length;
}
//判断串相等
bool StrEqual(SqString s,SqString t)
{
bool same=true;
int i;
if (s.length!=t.length)
same=false;
else
for (i=0; i<s.length; i++)
if (s.data[i]!=t.data[i])
{
same=false;
break;
}
return same;
}
//求串长
int StrLength(SqString s)
{
return s.length;
}
//串连接
SqString Concat(SqString s,
c语言 数据结构 串的顺序存储 学习记录
最新推荐文章于 2022-07-09 09:23:44 发布