ch27-6.c
来自「C语言程序设计上机指导与练习 冶金工业出版社 刘怀亮」· C语言 代码 · 共 24 行
C
24 行
#include "stdio.h"
strcmp(p1,p2)
char *p1,*p2;
{
int i;
i=0;
while(*(p1+i)==*(p2+i))
if(*(p1+i++)=='\0') return(0);
return(*(p1+i)-*(p2+i));
}
void main()
{
int m;
char str1[20],str2[20],*p1,*p2;
printf("Input two strings(1 string at each line):\n");
scanf("%s",str1);
scanf("%s",str2);
p1=&str1[0];
p2=&str2[0];
m=strcmp(p1,p2);
printf("The result of comparison :%d\n",m);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?