①二维数组
#includevoid main() { int i; char sz[3][20]={"CSDN","世界","你好"}; for(i=0;i<3;i++) { printf("%s ",sz[i]); } printf("n"); }
结果:
CSDN 世界 你好 Press any key to continue
②指针
#includevoid main() { int i; char *p[3]={"hello","世界","hi"}; for(i=0;i<3;i++) { printf("%s ",p[i]); } printf("n"); }
结果:
hello 世界 hi Press any key to continueC++
#include#include using namespace std; int main() { string h[3]={"第一个字符串","第二个字符串","第三个字符串"}; for(int i=0;i<3;i++) { cout< 结果:
第一个字符串 第二个字符串 第三个字符串 -------------------------------- Process exited after 3.853 seconds with return value 0 请按任意键继续. . .



