7

I was looking for this on internet and in every place with the functions of string.h these two are not mentioned.

Is because what? They aren't in every compiler?

ks1322
  • 31,484
  • 13
  • 100
  • 154
exsnake
  • 1,584
  • 2
  • 18
  • 37

3 Answers3

15

They are non-standard functions from Microsoft's C library. MS has since deprecated them in favor of renamed functions _strlwr() and _strupr():

Note that the MS docs claim they are POSIX functions, but as far as I can tell they never have been.

If you need to use them on a non-MS toolchain, they're easy enough to implement.

char* strlwr(char* s)
{
    char* tmp = s;

    for (;*tmp;++tmp) {
        *tmp = tolower((unsigned char) *tmp);
    }

    return s;
}
AJM
  • 1,014
  • 12
  • 23
Michael Burr
  • 321,763
  • 49
  • 514
  • 739
  • They're also supported by gcc, even if you try to force standards-compliance with something like `-std=c11`. – AJM May 05 '21 at 17:34
  • Regarding them being POSIX functions - there's a searchable online version of POSIX.1-2017 hosted at https://pubs.opengroup.org/onlinepubs/9699919799/ - and they're definitely not mentioned in it. – AJM May 05 '21 at 19:58
  • Also, you might want to add `#include ` in that code snippet, since `tolower` needs it and `strlwr` needed `` instead. – AJM May 05 '21 at 20:03
4

These functions are not C standard functions. So it is implementation-defined whether they are supported or not.

Vlad from Moscow
  • 265,791
  • 20
  • 170
  • 303
1

These functions are not standard, and in fact their signatures are broken/non-usable. You cannot case-map a string in-place in general, because the length may change under case mapping.

R.. GitHub STOP HELPING ICE
  • 201,833
  • 32
  • 354
  • 689