返回信息流腾讯模拟笔试题--数组指针强制类型转换'int*'到'int*[5]'编译出错
报错:C-style cast from 'int*' to 'int*[5]' is not allowed.
怎么解决,请教各位大神??难道题目错了??
题目意思了解,可是为什么不能跑起来?
#include<stdio.h>
int main(){
const int N = 10;
const int M = 2;
int * a = new int[N];
for(int i = 0; i < N; ++i)
a[i] = (0 == i % 2) ? (i + 2) : (i);
int (*b)[N / M] = (int*[N / M])a;//这句话编译报错
for(i = 0; i < M; ++ i){
for(int j = 0; j < N / M; ++j)
printf("%d", b[i][j]);
}
return 0;
}
这是一条镜像帖。来源:北邮人论坛 / cpp / #94977同步于 2017/3/27
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
腾讯模拟笔试题--数组指针强制类型转换'int*'到'int*[5]'编译出
huodan1993
2017/3/27镜像同步2 回复
订阅后,新回复会通过你的通知中心匿名送达。
2 条回复