所以基本上我有一個數組,看起來像這樣:C++字符數組查找/替換一個char
char array[25];
我有一個「X」擺在那裏,和24「0'。我試圖創建一個函數,我可以在數組中找到'X'的位置,所以每當輸入控件時我都可以移動它。下面是一些代碼,用於瞭解我在想什麼,我只是想不能把它放在一起。
int findX(){
//make this find the location of X out of the 25 char array.
//then return the slot of X as a number, like if it's in the 20th slot, then it will return 20 ?
//return(locationOfX);
}
也許你需要[一個很好的入門書(HTTP://計算器.COM /問題/ 388242 /對,最終-C-書指南和列表)?因爲它應該教會你自己解決問題的所有知識。 –
使用std :: string! – 2017-10-16 07:01:13