[英]error: Void Value not ignored as it ought to be, C programming
我只想問一個非常快速的問題。 我在我的C代碼中一直遇到問題,它說
error: void value not ignored as it ought to be
我的代碼正在發生的問題是在調用語句中,以便函數運行
m = myMax1(a,len,m);
無效的函數如下:
void myMax1( int *arr, int *max, int n )
{
max = arr[0];
for(n = 0; n < max; n++)
{
if(arr[n]>max)
{
max = arr[n];
}
}
}
如果您有任何解決方案,請告訴我! 非常感謝你!
您的函數未返回任何內容,但您正在將返回值分配給變量m
。 如果僅出於副作用而調用它,請不要將返回值設置為任何值。
當函數返回void
,不能使用:
m = myMax1(a,len,m);
您可以使用:
myMax1(a,len,m);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.