xref: /curl/docs/libcurl/curl_strequal.md (revision e3fe0200)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_strequal
5Section: 3
6Source: libcurl
7See-also:
8  - strcasecmp (3)
9  - strcmp (3)
10Protocol:
11  - All
12---
13
14# NAME
15
16curl_strequal, curl_strnequal - case insensitive string comparisons
17
18# SYNOPSIS
19
20~~~c
21#include <curl/curl.h>
22
23int curl_strequal(const char *str1, const char *str2);
24int curl_strnequal(const char *str1, const char *str2, size_t length);
25~~~
26
27# DESCRIPTION
28
29The curl_strequal(3) function compares the two strings *str1* and
30*str2*, ignoring the case of the characters. It returns a non-zero (TRUE)
31integer if the strings are identical.
32
33The **curl_strnequal()** function is similar, except it only compares the
34first *length* characters of *str1*.
35
36These functions are provided by libcurl to enable applications to compare
37strings in a truly portable manner. There are no standard portable case
38insensitive string comparison functions. These two work on all platforms.
39
40# EXAMPLE
41
42~~~c
43int main(int argc, char **argv)
44{
45  const char *name = "compare";
46  if(curl_strequal(name, argv[1]))
47    printf("Name and input matches\n");
48  if(curl_strnequal(name, argv[1], 5))
49    printf("Name and input matches in the 5 first bytes\n");
50}
51~~~
52
53# AVAILABILITY
54
55Always
56
57# RETURN VALUE
58
59Non-zero if the strings are identical. Zero if they are not.
60