home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_10 / 9n10077b < prev    next >
Text File  |  1991-08-21  |  948b  |  48 lines

  1. /*
  2.  *  func_arg.c
  3.  *  Jerzy Tomasik, 20-Jul-1991
  4.  *  Stack usage during function calls
  5.  *  in a C program
  6.  */
  7.  
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10.  
  11. struct big_struct
  12.     {
  13.     char array[1024];
  14.     };
  15.  
  16. /*  A copy of big_struct is passed to this function
  17.  *  on the stack, 1024 bytes of stack space are
  18.  *  used to store the copy. The function does not
  19.  *  have access to the original structure
  20.  */
  21. void by_value(struct big_struct big, int dummy)
  22.     {
  23.     }
  24.  
  25. /*  An address of big_struct is passed to this function.
  26.  *  This uses only 2 bytes of stack space (under small
  27.  *  memory model), but any changes to the structure
  28.  *  will be reflected in the original. This is NOT
  29.  *  a copy!
  30.  */
  31. void by_address(struct big_struct *big, int dummy)
  32.     {
  33.     }
  34.  
  35.  
  36. int main(void)
  37.     {
  38.     struct big_struct big;
  39.     int dummy;
  40.  
  41.     by_value(big, dummy);
  42.  
  43.     by_address(&big, dummy);
  44.  
  45.     return(0);
  46.     }
  47.  
  48.