gpt4 book ai didi

c - C中每个单词首字母的简单大写

转载 作者:太空宇宙 更新时间:2023-11-04 02:53:10 25 4
gpt4 key购买 nike

<分区>

我想将输入字符串中每个单词的首字母大写。

这就是我所做的(还行​​不通)

void main() {
char sentence[100];
int i;

printf("Enter your name and surnames: ");
gets(sentence);

for(i = 0; i<strlen(sentence); i++){
if(sentence[i] == ' '){
printf("%c", toupper(sentence[i]+1));
//I want to advance to next item respect to space and capitalize it
//But it doesn't work
} else {
printf("%c", sentence[i]);
}
}
}

输入:詹姆斯·卡梅隆

希望输出:詹姆斯·卡梅隆

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com