Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

C programming/C reference/nonstandard/strcasecmp

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

In programming language C, strcasecmp is a function declared in the strings.h header file (or sometimes in string.h) that compares two strings irrespective of the case of characters. This function is in POSIX.1-2001. Prototype int strcasecmp(const char *f1, const char *f2); This function returns an integer i : i > 0, if lowercase(f1) is greater than lowercase(f2) i < 0, if lowercase(f1) is found less than string lowercase(f2) and i = 0, if lowercase(f1) is equal to lowercase(f2). Example # include <stdio.h> # include <strings.h> int main(int argc, char *argv[]){ int i; if(argc != 3){ printf("bad input\n"); return 1; } i = strcasecmp(argv[1], argv[2]); if (i == 0) printf("'%s' equals '%s'\n", argv[1], argv[2]); else if (i > 0) printf("'%s' is greater than '%s'\n", argv[1], argv[2]); else if (i < 0) printf("'%s' is less than '%s'\n", argv[1], argv[2]); return 0; }