這是我的程序的示例代碼。作爲一個函數的數組的雙指針
我有一個函數名爲function
這是用來返回一個整數值和整數數組。我必須通過它們作爲指針(function
的簽名不能更改)。所以我寫了下面的代碼。在這裏,我必須將值分配給傳遞給函數的雙指針。
void function(unsigned int* count, unsigned int ** array)
{
for(unsigned int i = 0; i<4;i++)
{
//array[i] = (unsigned int*)i*10;
}
*count = 4;
}
int main()
{
unsigned int count;
unsigned int array2[4];
function(&count, (unsigned int**)&array2);
return 0;
}
但上述代碼不起作用。
您的程序不會產生任何可觀察的輸出。它怎麼能證明你的問題?在某些時候,你必須**測試**看看它是否有效。 –
我的主要需求是使用指定的值在函數'function'中填充數組'array2'。我在VS中調試代碼來檢查它是否正常工作。 –