The function strupr()
is not a standard C library function. It appears that you may be referring to a non-standard function that is available in some C libraries or compiler-specific libraries. The purpose of this function is to convert a C-style string to uppercase.
If you want to convert a C-style string to uppercase using standard C library functions, you can use the toupper()
function along with a loop. Here’s an example of how you can achieve this:
#include <ctype.h> #include <stdio.h> void strToUpper(char* str) { int i = 0; while (str[i] != '\0') { str[i] = toupper(str[i]); i++; } } int main() { char str[] = "Hello, World!"; printf("Before: %s\n", str); strToUpper(str); printf("After: %s\n", str); return 0; }
In the code above, the strToUpper()
function takes a C-style string as input and converts each character to uppercase using the toupper()
function from the ctype.h
header. The function continues until it encounters the null terminator character ('\0'
), indicating the end of the string.
Please note that the toupper()
function expects an unsigned char or EOF (end-of-file) as its input, so it’s important to cast the character to unsigned char
before passing it to toupper()
.