7213709-C-Programming

Page 48

than this. This is by using a special kind of parameter, often called a variable parameter. It is most easily explained with the aid of an example:

#include <stdio.h> main () { int i,j; GetValues (&i,&j); printf ("i = %d and j = %d",i,j) } /************************************/ GetValues (p,q) int *p,*q; { *p = 10; *q = 20; }

To understand fully what is going on in this program requires a knowledge of pointers and operators, which are covered in later sections, but a brief explanation can be given here, so that the method can be used. There are two new things to notice about this program: the symbols & and *. The ampersand & symbol should be read as "the address of..". The star * symbol should be read as "the contents of the address...". This is easily confused with the multiplication


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.