二十五岁时我们都一样愚蠢、多愁善感,喜欢故弄玄虚,可如果不那样的话,五十岁时也就不会如此明智。
标题:C实例 比较字符串
C实例 比较字符串
#include <stdio.h> int main() { char s1[] = "advise"; char s2[] = "advice"; int n = 0; unsigned short flag = 1; while (s1[n] != '\0') { if(s1[n] != s2[n]) { flag = 0; break; } n++; } if(flag == 1) { printf("%s and %s are identical\n", s1, s2); } else { printf("%s and %s are NOT identical\n", s1, s2); } return 0; }