我試圖在c中將char *
轉換爲大寫字母,但功能toupper()
在此處不起作用。將字符*轉換爲大寫字母C
我試圖得到temp的值的名稱,名稱是冒號前的任何東西,在這種情況下它是「測試」,然後我想充分利用名稱。
void func(char * temp) {
// where temp is a char * containing the string "Test:Case1"
char * name;
name = strtok(temp,":");
//convert it to uppercase
name = toupper(name); //error here
}
我得到的錯誤,函數toupper期望一個int,但收到一個char *。事情是,我必須使用char *的函數,因爲這是函數所採用的,(我不能在這裏真正使用char數組,我能嗎?)。
任何幫助將不勝感激。
也許我會刪除這個答案,因爲它不會增加價值,但是DV的原因是什麼? –