【发布时间】:2017-11-25 02:27:52
【问题描述】:
我的功能需要帮助,这就是我所做的。
void ShuffleCards(int (*deck_of_cards)[NUM_CARDS])
{
int i = 51;
int j, temp;
while(i>0)
{
j = rand()%(i+1);
temp = *deck_of_cards[i];
*deck_of_cards[i] = *deck_of_cards[j];
*deck_of_cards[j] = temp;
i--;
}
}
我遇到了分段错误,因为我不确定在交换发生之前必须正确编码什么。请帮帮我。
【问题讨论】:
-
欢迎来到 stackoverflow.com。请花一些时间阅读the help pages,尤其是名为"What topics can I ask about here?" 和"What types of questions should I avoid asking?" 的部分。也请take the tour 和read about how to ask good questions。最后请学习如何创建Minimal, Complete, and Verifiable Example。