2024-12-07 04:24:00 +00:00
|
|
|
int printf(char* format, ...);
|
2024-11-28 14:50:12 +00:00
|
|
|
|
2024-12-07 04:24:00 +00:00
|
|
|
int strcmp(char* s1, char* s2) {
|
2024-11-28 14:50:12 +00:00
|
|
|
while (*s1 && *s2 && *s1 == *s2) {
|
|
|
|
s1++;
|
|
|
|
s2++;
|
|
|
|
}
|
|
|
|
return *s1 - *s2;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
2024-12-07 04:24:00 +00:00
|
|
|
char* s1 = "helloworld";
|
|
|
|
char* s2 = "world";
|
2024-11-28 14:50:12 +00:00
|
|
|
printf("%d\n", strcmp(s1, s2));
|
|
|
|
printf("%d\n", strcmp(s1 + 5, s2));
|
|
|
|
}
|