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