|
Last change
on this file since 0c834c5 was 0580615, checked in by Thomas Lopatic <thomas@…>, 8 years ago |
|
Point of no return.
|
-
Property mode
set to
100644
|
|
File size:
427 bytes
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | =============================================================================
|
|---|
| 3 | strcmp.c -- compare strings
|
|---|
| 4 | Version 2 -- 1987-06-15
|
|---|
| 5 |
|
|---|
| 6 | Compare strings: s1>s2: >0 s1==s2: 0 s1<s2: <0
|
|---|
| 7 | =============================================================================
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | int strcmp(char *s1, char *s2)
|
|---|
| 11 | {
|
|---|
| 12 | if(s1 == s2)
|
|---|
| 13 | return(0);
|
|---|
| 14 |
|
|---|
| 15 | while(*s1 == *s2++)
|
|---|
| 16 | if(*s1++ == '\0')
|
|---|
| 17 | return(0);
|
|---|
| 18 |
|
|---|
| 19 | return((int)*s1 - (int)*--s2);
|
|---|
| 20 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.