Search code examples
cfunctiontoupper

toupper function in C


#include <stdio.h>
#include <ctype.h>

char* strcaps(char* s)
{
        while (*s != '\0')
        {
                toupper(*s);
                s++;
        }
        return s;
}

.

int main()
{
        char makeCap[100];
        printf("Type what you want to capitalize: ");
        fgets(makeCap, 100, stdin);
        strcaps(makeCap);
        return 0;
}

this program compiles just fine, but when I run it, it doesn't output anything. what am i missing here?


Solution

  • You are not printing anything!

    Print the return value of toupper().

            printf("%c",toupper(*s));