C语言中怎样定义一个字符型的二维数组赋值并输出啊?为什么总是报“array bound overflow数组越界呢?”比如这样定义:
str[30][30]={"hello\0""hello world\0"...}为什么不对呢?
#include<stdio.h>
#define M 5
#define N 3
void main()
{
int i,j;
char c[M][N]={'H','e','l','l','o',' ','c','!'};//定义数组
for(i=0;i<M;i++)//输出数组
for(j=0;j<N;j++)
printf("%c",c[i][j]);
printf("\n");
}
#define M 5
#define N 3
void main()
{
int i,j;
char c[M][N]={'H','e','l','l','o',' ','c','!'};//定义数组
for(i=0;i<M;i++)//输出数组
for(j=0;j<N;j++)
printf("%c",c[i][j]);
printf("\n");
}
温馨提示:答案为网友推荐,仅供参考