这是为什么,给我讲讲,谢谢
以下程序利用结构体指针输出一组化学元素名称及其原子量。请改正程序中的错误。struct list
{ int i;
char name[4];
float w;
}tab[4]={{1,"H",1.008}, {2,"He",4.0026}, {3,"Li",6.941}, {4,"Be",9.01218}};
# include “stdio.h”
void main( )
{ struct *p;
printf("No\tName\tAtomic Weight\n");
for (p=tab; p<4; p++)
printf("%d\t %s\t %f\n",
p->i, p->name, p->w);
}
我是这样改的为什么不对呢?
以下程序利用结构体指针输出一组化学元素名称及其原子量。请改正程序中的错误。
struct list
{ int i;
char name[4];
float w;
}tab[4]={{1,"H",1.008}, {2,"He",4.0026}, {3,"Li",6.941}, {4,"Be",9.01218}};
# include “stdio.h”
void main( )
{ struct list*p=tab;
printf("No\tName\tAtomic Weight\n");
for (p=tab; p<4; p++)
printf("%d\t %s\t %f\n",
p->i, p->name, p->w);
}