你好,我是做一個遊戲,我有一個記分牌在裏面。得分存儲在一個int變量中,但是用於遊戲的庫im需要一個字符數組來爲我的記分板輸出文本。
那麼我如何將一個int變成一個字符數組?
int score = 1234; // this stores the current score
dbText(100,100, need_the_score_here_but_has_to_be_a_char_array);
// this function takes in X, Y cords and the text to output via a char array
我使用的庫是DarkGDK。
tyvm :)
這也是我的建議。請記住.str()返回一個臨時對象,因此緩存.str()。c_str()的結果是一個糟糕的想法。 (這不適用於你的例子,但我想確保提到警告)。 – Tim 2010-09-27 20:44:19