根据百度百科的:http://baike.baidu.com/view/1026924.htm

函数简介

原型:extern int strcmp(const char *s1,const char * s2);

所在头文件:string.h

功能:比较字符串s1和s2。

一般形式:strcmp(字符串1,字符串2)

说明:

当s1<s2时,返回值= -1

当s1==s2时,返回值= 0

当s1>s2时,返回值 = 1

注:c++ 中

当s1<s2时,返回值小于0

当s1==s2时,返回值等于0

当s1>s2时,返回值 大于0

注意该函数在C中返回是1或者-1 而在C++中是小于0和大于0,不一定为1和-1.

如果按照c接口和1和-1比较会出错。

切记

posted on 2013-08-16 22:03  @且听风吟@  阅读(331)  评论(0)    收藏  举报