home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C Programming Starter Kit 2.0
/
SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso
/
tyc
/
list11_4.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-16
|
908b
|
42 lines
/* Demonstrates stepping through an array of structures */
/* using pointer notation. */
#include <stdio.h>
#define MAX 4
/* Define a structure, then declare and initialize */
/* an array of 4 structures. */
struct part {
int number;
char name[10];
} data[MAX] = {1, "Smith",
2, "Jones",
3, "Adams",
4, "Wilson"
};
/* Declare a pointer to type part, and a counter variable. */
struct part *p_part;
int count;
main()
{
/* Initialize the pointer to the first array element. */
p_part = data;
/* Loop through the array, incrementing the pointer */
/* with each iteration. */
for (count = 0; count < MAX; count++)
{
printf("\nAt address %d: %d %s", p_part, p_part->number,
p_part->name);
p_part++;
}
}