一,字符串比较
参考代码:
int fun(char* p, char* q) {int i = 0;while (*p == *q) {if (*p == '\0')return 0;else p++, q++;}return *p - *q;
}
void main() {int n = fun("goods", "people");printf("%d", n);
}
运行结果:
二,字符串逆序输出
参考代码:
void fun(char* w,int m) {char t, * p1,*p2;p1 = w;p2 = w+m-1;while (p1 < p2){t = *p1;*p1 = *p2;*p2 = t;p1++;p2--;}
}
void main()
{char a[] = "ABCDEFG";fun(a,strlen(a));puts(a);
}