BUG :warning C4047: 'function' : 'int *' differs in levels of indirection from 'int '

C语言初学遇到的bug:

/*将一个数组逆序输出*/
#include<stdio.h>
#define MAXSIZE 6

void nixu(int array[MAXSIZE]);
int main(){
    int i;
    int array[MAXSIZE]={12,24,5,13,10,9};
    //原数组
    for(i=0;i<MAXSIZE;i++){
    printf("原数组:%d\n",array[i]);
    }
    //逆序输出数组
       nixu(array[MAXSIZE]);
    return 0;
}
void nixu(int array[MAXSIZE]){
    int j;
    for(j=MAXSIZE-1;j>=0;j--){
     printf("数组逆序1: %d\n",array[j]); 
    }
  }
}

Compile(Ctrl+F7)出现警告:

C:\fastwork\Study\VisualWork\CStudy\数组逆序.c(15) : warning C4047: 'function' : 'int *' differs in levels of indirection from 'int '
C:\fastwork\Study\VisualWork\CStudy\数组逆序.c(15) : warning C4024: 'nixu1' : different types for formal and actual parameter 1
Linking...

运行崩溃:

bug.png

解决方式://逆序输出数组处的 nixu(array[MAXSIZE])→,→nixu(array)。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容