1
#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?

ajb
  • 31,309
  • 3
  • 58
  • 84
Jakkie Chan
  • 317
  • 4
  • 14

3 Answers3

1

You are not printing anything!

Print the return value of toupper().

        printf("%c",toupper(*s));
P.P
  • 117,907
  • 20
  • 175
  • 238
0

You don't print anything, so of course it won't output anything.

Charles Clayton
  • 17,005
  • 11
  • 87
  • 120
0
char* strcaps(char* s){
    char *p;
    for (p=s; *p; ++p)
        *p = toupper(*p);//maybe you want to change the original
    return s;//your cord : return address point to '\0'
}
...
//main
printf("%s", strcaps(makeCap));
BLUEPIXY
  • 39,699
  • 7
  • 33
  • 70