#include
#include
#include
#defineNULL
0
#defineok
1
#defineerror 0
#defineMAXSIZE 100
typedef struct{
char*ch;
int length;
}HString;
void newline();
void HStrMenu();
void HStrAssign(HString *S,char *chars);
void OutputStr(HString *S);
int
StrLength(HString *S);
int
StrConpare(HString *S,HString *T);
main()
{ intx=0;
char y,chars[MAXSIZE];
HString *S,*T;
do
{clrscr();HStringMenu();
printf("Input the number: ");
scanf("%d",&x); newline();
switch(x)
{
case 1:
printf("\nPlease input the chars:\n");
gets(chars);
newline();
HStrAssign(S,chars);
break;
case 2:
OutputStr(S);
break;
case 3:
printf("\nThe length of the String is %d. \n",StrLength(S));
case 4:
if(StrConpare(S,T)>0)printf("\nS>T.\n");
if(StrConpare(S,T)==0)printf("\nS=T.\n");
if(StrConpare(S,T)T,返回>0。若S=T,返回=0。若S<T,返回<0。*/
{ int i=0;
for(i=0;(i<(*S).length)&&(i<(*T).length);++i)
{ if((*S).ch!=(*T).ch)return (*S).ch-(*T).ch;
else return (*S).ch-(*T).ch;
}
}
关于
void newline();
void HStrMenu();
两个函数申明很简单就是输出目录和清行
|