The program is wrong. The following program is used to print out all the elements of the structure array.
struct s
{ char name[10]; int age; } main() { struct sa[3] = {”John”,19,”Paul”,17,”Marry”,18}; int *p;
for(p = a; p < 3; p++)
{
printf("%s,%d\n", p->name, p->age );
}
}
answer:
#include<stdio.h>
struct s
{
char name[10];
int age;
};
int main()
{
struct s a[3] = {
{
"John",19},
{
"Paul",17},
{
"Marry",18}
};
struct s *p = a;
for(p = a; p < &a[3]; p++)
{
printf("%s,%d\n", (*p).name, (*p).age );
}
}