Can someone show me what StrCmp looks like written out?
Can someone show me what StrCmp looks like written out?
This was taken from the help file from my compiler : Borland c++ 5.02
Code:#include <string.h> #include <stdio.h> int main(void) { char *buf1 = "aaa", *buf2 = "bbb", *buf3 = "ccc"; int ptr; ptr = strcmp(buf2, buf1); if (ptr > 0) printf("buffer 2 is greater than buffer 1\n"); else printf("buffer 2 is less than buffer 1\n"); ptr = strcmp(buf2, buf3); if (ptr > 0) printf("buffer 2 is greater than buffer 3\n"); else printf("buffer 2 is less than buffer 3\n"); return 0; }
theres also an "strcmpi" that compares without case sensitivity
Last edited by biosninja; 11-22-2002 at 12:57 AM.
Its not compaticle with ANSI i guess its a borland function ??theres also an "strcmpi" that compares without case sensitivity
"I wish i could wish my wishs away"
"By indirections find directions out" -- William Shakespears
"Do what thou wilt shall be the whole of the law" -- Crowley "THE BEAST 666"
Mizra -> love = Death...
RDB(Rocks yooo)..
http://www.cbeginnersunited.com
Are you ready for the Trix ???
No I mean the function itself not using it.
?No I mean the function itself not using it.
string compare?
i think he means like whats string compare doing??????
guns dont kill people, abortion clinics kill people.
strcmp performs an unsigned comparison of s1 to s2, starting with the first character in each string and continuing with subsequent characters until the corresponding characters differ or until the end of the strings is reached.i think he means like whats string compare doing??????
Return Value
If s1 is... return value is...
less than s2 < 0
the same as s2 == 0
greater than s2 > 0
s1 = string 1
s2 = string 2
From K&R2
Code:/* strcmp: return <0 if s<t, 0 if s==t, >0 if s>t */ int strcmp(char *s, char *t) { for ( ; *s == *t; s++, t++) if (*s == '\0') return 0; return *s - *t; }
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]