strnicmp

 

stricmp는 두개의 스트링을 설정 사이즈 length만큼 비교하는 함수이다. 이 함수는 대소문자 구별을 하지 않는다.

 

int @strnicmp(string string1, string string2, int length);

 

함수인자

string string1 : 비교할 첫번째 문자열

string string2 : 비교할 두번째 문자열

int length : 비교할 글자수

 

반환 값

String1과 string2 가 같다면                     retn -> 0

String1이 string2 보다 더 크다면             retn -> 1

String2가 string1 보다 더 크다면             retn -> -1

 

예제1

int retn=@strnicmp(char *string1, char *string2, int length);

문장설명  :  string1의 문자열과 string2의 문자열을 설정 사이즈 length만큼 비교해서 그 결과값을 retn에 넘겨준다.

 

예제2

 string1과 string2가 같은 경우

 

int retn=@strnicmp("ABC","abcef", 3);

retn결과값은 ‘ 0 ‘ 이다.

 

Int retn=@strnicmp($STRING1, $STRING2, 3);  //(STIRNG1,STRING2는 문자열 태그이며, STRING1: "ABC", STRING2: "abcef"이다.)

retn 결과값은 ‘ 0 ’ 이다.

 

예제3

 string1이 string2보다 더 큰 경우

 

int retn=@strnicmp("def","abcdef");

retn결과값은 ‘ 1 ‘ 이다.

 

Int retn=@strnicmp($STRING1, $STRING2);  //(STIRNG1,STRING2는 문자열 태그이며, STRING1: "def", STRING2: "abcdef"이다.)

retn 결과값은 ‘ 1 ’ 이다.

 

예제4

 string2가 string1보다 더 큰경우

 

int retn=@strnicmp("abcdef","abc");

retn결과값은 ‘ -1 ‘ 이다.

 

Int retn=@strnicmp($STRING1, $STRING2);  //(STIRNG1,STRING2는 문자열 태그이며, STRING1: "abcdef", STRING2: "def"이다.)

retn 결과값은 ‘ -1 ’ 이다.