nsigned char SstringР [MAXSTRLEN + 1];Р // 0号单元存放串的长度Р串的连接算法中需分三种情况处理:РStatus Concat(SString S1, SString S2, SString &T) {Р //用T返回S1S2联接而成的新串。若未截断, 则返回TRUE,否则FALSE。Рif (S1[0]+S2[0] <= MAXSTRLEN) 、{// 未截断РT[1..S1[0]] = S1[1..S1[0]];РT[S1[0]+1..S1[0]+S2[0]] = S2[1..S2[0]];РT[0] = S1[0]+S2[0]; uncut = TRUE; Р} Рelse if (S1[0] <MAXSTRSIZE) { // 截断РT[1..S1[0]] = S1[1..S1[0]];РT[S1[0]+1..MAXSTRLEN] =S2[1..MAXSTRLEN-S1[0]];РT[0] = MAXSTRLEN;Рuncut = FALSE;Р}Рelse { // 截断(仅取S1)РT[0..MAXSTRLEN] = S1[0..MAXSTRLEN];Р // T[0] == S1[0] == MAXSTRLENРuncut = FALSE; Р}Рreturn uncut;Р} // ConcatР(2)串的堆分配存储表示Рtypedef struct {Р char *ch; Р // 若是非空串,则按串长分配存储区,Р // 否则ch为NULLР int length; // 串长度Р } HString;РStatus Concat(HString &T, HString S1, HString S2) {Р // 用T返回由S1和S2联接而成的新串Р if (T.ch) free(T.ch); // 释放旧空间