Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

strupper - Copy a string and convert to uppercase letters

&pagelevel(4)&pagelevel

Definition

#include <string.h>

char *strupper(char *s1, const char *s2);

strupper copies string s2 (including the null byte (\0)) to string s1, converting lowercase letters to uppercase in the process.

If string s2 is passed as a NULL pointer, the copy operation is not performed and the lowercase letters in s1 are converted to uppercase.
If s2 is not passed as a NULL pointer, s1 must be long enough to accept s2 including the null byte (\0).

Return val.

Notes

Pointer to the result string s1.

Strings terminated with the null byte (\0) are expected as arguments.

strupper does not check whether s1 is large enough for the result. If s1 is shorter than s2 (including the null byte), the memory space after s1 is overwritten!

The behavior is undefined if memory areas overlap.

Example

The following program copies the contents of s2 to s1, converting lowercase letters to uppercase in the process.

#include <stdio.h>
#include <string.h>
int main(void)
{
    char *s1 = "          ";
    char *s2 = "lowercase!";
    printf("Contents s2: %s\n", s2);
               /* Copy s2 to s1 and convert to uppercase*/
    strupper(s1, s2);
    printf("After strupper:\ncontents s1: %s\n", s1);
    return 0;
}

See also

strlower, tolower, toupper