+ 1
C strings comparison
Hi, I wanted to code a program in which the user has to input a string, and later compare it with another string that already initialized with a value. I want to convert the string entered by the user to upper case, and then compare it, so I used a function strcasecmp() to do so. I found that this function is not C standard, so I wanted to know which errors can this function generate and if there is another way to compare the strings using strupr() function or some other function that's C standard. Thanks in advance!
1 Odpowiedź
+ 5
This SO thread addresses what you're looking for
https://stackoverflow.com/questions/5820810/case-insensitive-string-comp-in-c
The top answer says:
"There is no function that does this in the C standard. Unix systems that comply with POSIX are required to have `strcasecmp` in the header strings.h; Microsoft systems have `stricmp`. To be on the portable side, write your own [...]"