/ ****************************************************************** * * Purpose: Program to demonstrate the use of strcmp. * Date: 05-Dec-96 * Author: M J Leslie. * Descrip: The standard strcmp returns 0 when the strings match * and indicates which string is lexigraphically greater. * Every time I have used strcmp, I have never been interested * in which string is greater and always frustrated that the * return code is inverted. This function tidys things up. * ******************************************************************/ #include <string.h> #include <stdio.h> #define TRUE 1 #define FALSE 0 int StringCompare(char *s1, char *s2); main() { char One[] = "Bartman"; char Two[] = "Batman"; int Ret; Ret = StringCompare(One, Two); if (Ret == TRUE) { puts("The Strings match"); } else { puts("The Strings do not match"); } } /**************************************************************/ int StringCompare(char *s1, char *s2) { int Ret; if (strcmp(s1, s2)) { Ret = 0; } else { Ret = 1; } return (Ret); }
file: /Techref/language/ccpp/Cref/EXAMPLES/strcmp.c, 1KB, , updated: 1998/1/27 09:52, local time: 2024/11/23 06:20,
3.133.146.94:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://techref.massmind.org/techref/language/ccpp/Cref/EXAMPLES/strcmp.c"> language ccpp Cref EXAMPLES strcmp</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to techref.massmind.org! |
.