所以我在過去的一個小時內擺弄它後真的很困惑。在C函數調用中使整數沒有投射的指針
我想在另一個函數內的另一個函數內調用一個函數。我收到一條錯誤消息:「傳遞displayDeck的參數1使得整型指針沒有轉換,預期的int *但參數的類型爲int。」
void printCard(int card)
{
char ranks[RANKS] = {'A','2','3','4','5','6','7','8','9','0','J','Q','K'};
char *suits = "SHDC";
printf("%c%c", ranks[card%RANKS], suits[card/RANKS]);
}
void displayDeck(int deck[])
{
int count = 0;
int cleanDisplay = 0;
while(count < MAXIMUM)
{
if(cleanDisplay == RANKS)
{
printf("\n");
cleanDisplay = 0;
}
printCard(deck[count]);
printf(" ");
cleanDisplay++;
count++;
}
printf("\n\n");
}
void dealCards(int deck[], int hands, int cards)
{
int total = hands * cards;
int counter = 0;
int counter2 = 0;
while(counter < total)
{
if(counter2 == cards)
{
printf("\nPlayer's Hand: \n");
counter2 = 0;
}
displayDeck(deck[counter]);
counter2++;
counter++;
}
}
displayDeck正在接受一個int,我在dealCards函數中調用它也是如此。所以我不確定這裏要做什麼。我可能需要實現另一個指針?我試圖從我創建和洗牌的數組中處理卡片。
我猜測錯誤是在printCard中的某處,因爲這是處理指針的唯一函數。
P.S我對C仍然比較陌生,所以如果這是一種比道歉更簡單的錯誤。