标签:str include col bsp nbsp 输出 tin 字符串 image
//比较字符串,输出首个不同字符的差值 # include<stdio.h> char c[50]={0}; char b[50]={0}; int strcmp1(char *a,char *b); int main() { gets(c); gets(b); printf("%d\n",strcmp1(c,b)); return 0; } int strcmp1(char *a,char *b) { int i=0,l; while(a[i]!=0) { i++; } l=i; i=0; while(i<=l) { if(a[i]==b[i]) { i++; continue; } else { return a[i]-b[i]; } } return 0;//a[last]=0,和b[last]相等,说明b[last]也是0,b也结束了 }
运行结果:
标签:str include col bsp nbsp 输出 tin 字符串 image
原文地址:https://www.cnblogs.com/bboykaku/p/12431620.html