qc.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
PFUNC.C
                                             Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
/* PFUNC.C: Passing pointers to a function. */
#include <stdio.h>
 
void swap( int *ptr1, int *ptr2 );
 
main()
{
   int first = 1, second = 3;
   int *ptr = &second;
   printf( "first: %d  second: %d\n", first, *ptr );
   swap( &first, ptr );
   printf( "first: %d  second: %d\n", first, *ptr );
}
 
void swap( int *ptr1, int *ptr2 )
{
   int temp;
   temp = *ptr1;
   *ptr1 = *ptr2;
   *ptr2 = temp;
}