65,186
社区成员




#include <iostream>
using namespace std;
int main(){
int** pint = NULL;
pint = new int* [5];
for(int i=0;i<5;i++){
pint[i] = new int[10];
memset(pint[i], -1 , 10);//①为什么不能准确赋初始值?测了下发现初始值为0是可以的
}
for(int i=0;i<5;i++)
for(int j=0;j<10;j++)
printf("%d\t",pint[i][j]);
//②以下为什么运行会出错???怎么解决?
char** pstr = NULL;
pstr = new char* [5];
for(int i=0;i<5;i++){
pstr[i] = new char[10];
memset(pstr[i], '*' , 10);
}
for(int i=0;i<5;i++)
for(int j=0;j<10;j++)
printf("%s\t",pstr[i][j]);
return 0;
}