我正在與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