如果字数组的大小没有从主函数传递,该程序只显示一个输出“Hiii”。
如果内部disp
函数产生大小显示
尺寸:48
大小:2
HIII二维字符数组的sizeof()显示错误o/p
如果尺寸是从main
函数传递显示
尺寸:48
尺寸:48
HIII
你好
你好有
Hello World
#include<stdio.h>
#include<conio.h>
void disp(char words[][12],int size)
{
int i,j;
char *p,*cp;
p=words;
size=sizeof(words);
printf("Size %d\n",size);
for(cp=p;cp<(p+size);cp+=12)
{
printf("%s",cp);
printf("\n");
}
}
void main()
{
char words[][12]={"Hiii","Hello","Hello There","Hello World"};
int size;
clrscr();
size=sizeof(words);
printf("Size %d\n",size);
disp(words,size);
getch();
}
btw这不是'作业' – Sourav 2012-03-20 03:33:01
可能的重复[C编程语言中的数组的大小?](http://stackoverflow.com/questions/1975128/sizeof-an-阵列内式C-编程语言) – 2012-03-20 13:56:53