C语言单个单词首字母大写

c语音中,单个单词怎么把首字母大写其余变小写?比如afggDFF要变成Afggdff

#include <stdio.h>
int main()
{
    char word[50],i=1;
    scanf("%s",word);
    if(word[0] >='a' && word[0] <='z')
          word[0] -= 32;
    while(word[i] != 0)
    {
        if(word[i] >='A' && word[i] <='Z')
            word[i] += 32;
        i++;
    }
    printf("%s",word);
    return 0;
}

可以弄个for循环吧
先来个首元素toupper,
判断语句来个islower,
变小写来个tolower.
代码有些不简洁。但我觉的更好理解。

#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main()
{
    char arr[] = "afggDFF";
    int i = 0;
    for (i = 0; i < strlen(arr); i++)
    {
        if (0 == i)
        {
            if (islower(arr[i]))
                arr[i] = toupper(arr[i]);
        }
        else
        {
            if (isupper(arr[i]))
                arr[i] = tolower(arr[i]);
        }

    }
    printf("%s", arr);
    return 0;
}