-3
#include <stdio.h>
#include <string.h>

int main(){
    char n[] = "NAME";
    strlwr(n);
    printf("%s", n);
    return 0;
}

I just wanted to print lower case "NAME" word but it doesn't work

string.c: In function ‘main’:
string.c:6:9: warning: implicit declaration of function ‘strlwr’; did you mean  strlen’? [-Wimplicit-function-declaration]
    6 |         strlwr(n);
      |         ^~~~~~
      |         strlen
/usr/bin/ld: /tmp/cc6E8Fyf.o: in function `main':
string.c:(.text+0x2f): undefined reference to `strlwr'
collect2: error: ld returned 1 exit status

according to C there is no function named strlwr() but I think there is function named so.

Pepijn Kramer
  • 9,356
  • 2
  • 8
  • 19
  • 3
    Why do you think there is a function by that name? – Shawn Feb 10 '23 at 08:01
  • Don't tag "C" questions with "C++", they are not the same languages (even though C++ has some backward compatibility with "C") – Pepijn Kramer Feb 10 '23 at 08:03
  • 1
    "I think there is function named so." - you thought incorrectly. There is no function by that name in the standard library. Some vendors provide such nuance, but it is not standard, and definitely not portable. – WhozCraig Feb 10 '23 at 08:06
  • What could you add to your question to differentiate it from: *According to C there is no function named gobbledygookery() but I think there is function named so*? If I can change the function name without invalidating a claim (it's still true that there is no such function in C), then your question deserves to have more details written out, more justifications for why people should believe you when you say the function exists. – JaMiT Feb 10 '23 at 08:33

1 Answers1

2

according to C there is no function named strlwr() but I think there is function named so.

strlwr() is not defined in the C standard. So it's implementation defined whether it is supported or not.

You can replicate its functionality with tolower() (from ctype.h).

toupper() converts the letter c to upper case, if possible.

The tolower() function has as a domain a type int, the value of which is representable as an unsigned char or the value of EOF. If the argument has any other value, the behavior is undefined. If the argument of tolower() represents an uppercase letter, and there exists a corresponding lowercase letter, the result shall be the corresponding lowercase letter.

See: undefined reference to `strlwr' for a sample implementation.

Harith
  • 4,663
  • 1
  • 5
  • 20
  • Although note ``tolower()`` is a single character conversion macro, not a string conversion... – Andrew Feb 10 '23 at 08:14