#include <string.h>
int strcmp(const char *s1, const char *s2);
#include <stdio.h>
#include <string.h>
int main ()
{
const char *p = "hello world";
const char *p1 = "hello";
const char *p2 = "hello world";
const char *p3 = "hello world32";
int k;
k = strcmp (p, p2);
printf ("两字符串相等,返回值为 %d\n", k);
k = strcmp (p, p1);
printf ("字符串1大于字符串2,返回值为 %d\n", k);
k = strcmp (p, p3);
printf ("字符串1小于字符串2,返回值为 %d\n", k);
return (0);
}
./strcmp
两字符串相等,返回值为 0
字符串1大于字符串2,返回值为 1
字符串1小于字符串2,返回值为 -1
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |