32 cout<<"please ensure the size of the array: "<<endl; 33 cin>>si; 34 cout<<"enter the members of the array: "<<endl; 35 char (*car)[20]=new char *[20]; 36 for (int i=0;i<si;i++) 37 { 38 cin>>car[i]; 39 } 40 cout<<"the longest string of this string array: "<<maxn(car,si)<<endl; 41 delete [] car;/******************************编译出错*******************************/edony:chapter8 edony$ vim 6.cppedony:chapter8 edony$ make 6c++ 6.cpp -o 66.cpp:35:31: error: expected expression char (*car)[20]=new char [][20]; ^6.cpp:35:12: error: cannot initialize a variable of type 'char (*)[20]' with an rvalue of type 'char *' char (*car)[20]=new char [][20]; ^ ~~~~~~~~6.cpp:35:32: error: expected ';' at end of declaration char (*car)[20]=new char [][20]; ^ ;3 errors generated.make: *** [6] Error 1
char (*car)[20]=new char (*)[20];试试? 追问 多谢解答,好像还有一点小问题。6.cpp:35:32: error: expected expression char (*car)[20]=new char (*)[20]; ^1 error generated. 追答 不好意思之前扯淡了。http://developer.51cto.com/art/201002/183127.htm 追问 非常感谢,对于二维数组初始化的问题,现在已经搞清楚了!谢谢你的解答……