- char words[3][4]= {"w","sds","ew"}; //第二个不能是“sdsf”,以为用数组定义字符串,后面会自动加上‘\0’;所以实际长度为5
- for (int i = 0; i<3; i++) { //字符输出
- for (int j=0; j<4; j++) {
- printf("%c ",words[i][j]);
- }
- printf("\n");
- }
-
- for (int k=0; k<3; k++) { //字符串输出
- printf("%s\n",words[k]);
- }
- return 0;
复制代码
|