Warning messages for all of my functions using pointers. Expected 'int*' but argument is of type 'int (*)[10]'

后端 未结 1 1448
既然无缘
既然无缘 2021-01-26 03:34

The code works fine I\'m just worried about the warning messages I\'m getting, would there be a way to make them not appear? Is there any reason to be worried about them? Also f

相关标签:
1条回答
  • 2021-01-26 04:01

    I think the error message is pretty self-describing.

    In your code, a is an array type, having int [10]. You pass &a, which is of type pointer to an array of 10 ints, or, int (*)[10] which is not the same type as a pointer to int, i.e., int *. Hence the compiler screams.

    As array type variables decay to the pointer to the first element of the array while passed as function arguments, you should call your function like

     readarray(a);
    
    0 讨论(0)
提交回复
热议问题