我下面有这个功能。该程序应该打印存储的编号。然而,这段代码 storedNumber = Array[*p][*q];
是一个疯狂的猜测。我需要使用typedef struct
吗?
void selectNumber( char userInput , int *p , int *q , char Array[NROW][NCOL] , char storedNumber )
{
/* Select the number chosen by the box */
if ( userInput == 'g' )
{
/* Select the number right below the box */
storedNumber = Array[*p][*q];
printf( "\n\n%c", storedNumber );
}
}
最佳答案
如果这就是你的函数想要做的所有事情,你不需要像 *p 和 *q 这样的参数,只需要 p 和 q 就足够了,因为它们不会在你的函数中改变。
另外storeNumber也是无用的参数,你可以在你的函数中声明一个。
此外,您应该检查 p>NROW 和 q>NCOL 是否阻止出站。
关于c - 如何将一个数组的变量值赋给另一个变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20063626/