home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C Programming Starter Kit 2.0
/
SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso
/
tyc
/
list9_3.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-16
|
733b
|
35 lines
/* Demonstrates using pointer arithmetic to access */
/* array elements with pointer notation. */
#include <stdio.h>
#define MAX 10
/* Declare and initialize an integer array. */
int i_array[MAX] = { 0,1,2,3,4,5,6,7,8,9 };
/* Declare a pointer to int and an int variable. */
int *i_ptr, count;
/* Declare and initialize a float array. */
float f_array[MAX] = { .0, .1, .2, .3, .4, .5, .6, .7, .8, .9 };
/* Declare a pointer to float. */
float *f_ptr;
main()
{
/* Initialize the pointers. */
i_ptr = i_array;
f_ptr = f_array;
/* Print the array elements. */
for (count = 0; count < MAX; count++)
printf("\n%d\t%f", *i_ptr++, *f_ptr++);
}