我正在与C玩弄。我的程序会提示用户输入他们想要定义的单词。然后我的程序使用CURL和字典API来返回定义。我的问题是定义格式不正确,所以我想这样做。这导致我的问题。用C替换另一个字母C
我需要大写句子的第一个单词。该定义采用char *格式。我不确定使用哪个C字符串函数。
我到目前为止所做的是将定义的第一个字符复制到它自己的char变量中。然后使用toupper()将其转换为大写。我不知道如何用新的大写字母替换定义字符串中的小写字母。
下面是一些代码。
char upperCase;
strncpy(&upperCase, r, 1); //copy first char of definition to upperCase (to be converted to uppercase)
printf("%c\n", toupper(upperCase)); //just prints the uppercase letter to make sure it works
printf("%s\n", r); //print the definition
r是定义的字符串。
为什么不显示你到目前为止的代码? –
http://stackoverflow.com/a/20036880/1067211 – Avery
欢迎来到SO。请阅读[问]如何撰写适当的问题。这样你会得到更好的回应。 – OldProgrammer