Case.cc File Reference
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>

Functions

charstrtolower (char *str)
 Converts a string to all lower case. More...
 
charstrtoupper (char *str)
 Converts a string to all upper case. More...
 
int strcicmp (const char *s1, const char *s2)
 Case-insensitive string comparison. More...
 

Function Documentation

◆ strcicmp()

int strcicmp ( const char s1,
const char s2 
)

Case-insensitive string comparison.

The original strings are not overwritten.

Parameters
[in]s1A C-string (char*)
[in]s2A C-string (char*)
Returns
As with strcmp, returns 0 if the strings are identical up to case, and otherwise 1.
42 {
43  char* t1 = (char*) calloc(strlen(s1) + 1, sizeof(char));
44  char* t2 = (char*) calloc(strlen(s2) + 1, sizeof(char));
45  strncpy(t1, s1, strlen(s1));
46  strncpy(t2, s2, strlen(s2));
47  strtolower(t1);
48  strtolower(t2);
49  int out = strcmp(t1, t2);
50  if (out != 0)
51  out = 1;
52 
53  free(t1);
54  free(t2);
55  return out;
56 }
char * strtolower(char *str)
Converts a string to all lower case.
Definition: Case.cc:15
std::ofstream out("Result.txt")

References out(), and strtolower().

◆ strtolower()

char* strtolower ( char str)

Converts a string to all lower case.

The original string is overwritten.

Parameters
[in]strA C-string (char*), that will be overwritten.
Returns
str
16 {
17  for (int i = 0; i < strlen(str); i++)
18  str[i] = tolower(str[i]);
19  return str;
20 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
str
Definition: compute_granudrum_aor.py:141

References i, and compute_granudrum_aor::str.

Referenced by strcicmp().

◆ strtoupper()

char* strtoupper ( char str)

Converts a string to all upper case.

The original string is overwritten.

Parameters
[in]strA C-string (char*), that will be overwritten.
Returns
str
28 {
29  for (int i = 0; i < strlen(str); i++)
30  str[i] = toupper(str[i]);
31  return str;
32 }

References i, and compute_granudrum_aor::str.