?? main4-2.c
字號:
/* main4-2.c 檢驗bo4-2.c的主程序 */
#include"c1.h"
#include"c4-2.h"
#include"bo4-2.c"
void main()
{
int i;
char c,*p="God bye!",*q="God luck!";
HString t,s,r;
InitString(&t); /* HString類型必需初始化 */
InitString(&s);
InitString(&r);
StrAssign(&t,p);
printf("串t為: ");
StrPrint(t);
printf("串長為%d 串空否?%d(1:空 0:否)\n",StrLength(t),StrEmpty(t));
StrAssign(&s,q);
printf("串s為: ");
StrPrint(s);
i=StrCompare(s,t);
if(i<0)
c='<';
else if(i==0)
c='=';
else
c='>';
printf("串s%c串t\n",c);
Concat(&r,t,s);
printf("串t聯接串s產生的串r為: ");
StrPrint(r);
StrAssign(&s,"oo");
printf("串s為: ");
StrPrint(s);
StrAssign(&t,"o");
printf("串t為: ");
StrPrint(t);
Replace(&r,t,s);
printf("把串r中和串t相同的子串用串s代替后,串r為:\n");
StrPrint(r);
ClearString(&s);
printf("串s清空后,串長為%d 空否?%d(1:空 0:否)\n",StrLength(s),StrEmpty(s));
SubString(&s,r,6,4);
printf("串s為從串r的第6個字符起的4個字符,長度為%d 串s為: ",s.length);
StrPrint(s);
StrCopy(&t,r);
printf("復制串t為串r,串t為: ");
StrPrint(t);
StrInsert(&t,6,s);
printf("在串t的第6個字符前插入串s后,串t為: ");
StrPrint(t);
StrDelete(&t,1,5);
printf("從串t的第1個字符起刪除5個字符后,串t為: ");
StrPrint(t);
printf("%d是從串t的第1個字符起,和串s相同的第1個子串的位置\n",Index(t,s,1));
printf("%d是從串t的第2個字符起,和串s相同的第1個子串的位置\n",Index(t,s,2));
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -