字符串操作函数

来源:百度知道 编辑:UC知道 时间:2024/07/05 09:07:07
跪求数据结构中字符串的清空和销毁、插入和删除、Replace的代码

我用pascal

1.求长度length
定义:function Length(S: String): Integer;

2.复制子串copy
定义: function Copy(S: String; Index: Integer; Count: Integer): String;

3.插入子串insert
定义:procedure Insert(Source: String; var S: String; Index: Integer);

4.删除子串delete
定义:procedure Delete(var S: String; Index: Integer; Count:Integer);

5.字符串转为数值val
定义: procedure Val(S; var V; var Code: Integer);

6.数值转为字符串str
定义: procedure Str(X [: Width [: Decimals ]]; var S:string);

7.求子串起始位置pos
定义:function Pos(Substr: String; S: String): Byte;

8.字符完全串连+
定义:操作符+把两个字符串联在一起。

9.字符串压缩空格串连-
定义:操作符-去掉第一个字符串最后的空格后,将两个字符串联在一起。