home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / dos / prg / alb_c10 / chap_14 / ch14_05.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-08  |  874 b   |  32 lines

  1. /*********************************************************************
  2. *  CH14_05.C                         RΘallocation de mΘmoire  *
  3. *********************************************************************/
  4.  
  5. #include<stdio.h>
  6. #include<alloc.h>
  7. #include<string.h>
  8.  
  9. main( void)
  10. {
  11.     char *chaine;
  12.  
  13.     chaine= ( char*) calloc( 16u, sizeof( char) );
  14.  
  15.     printf("\n Le 1er contenu de \"chaine\" est: %s\n"
  16.            " et son adresse: %d", chaine, chaine);
  17.  
  18.     strncpy( chaine, "Hello World!", 15u);
  19.     /* C'est la premiΦre phrase prise comme exemple dans livre de
  20.                      Kernighan & Ritchie, les inventeurs du C.*/
  21.  
  22.     printf("\n Le 2Φme contenu de \"chaine\" est: %s\n"
  23.            " et son adresse: %d", chaine, chaine);
  24.  
  25.     chaine= (char*) realloc( chaine, 120u);
  26.  
  27.     printf("\n Le dernier contenu de \"chaine\" est: %s\n"
  28.            " et son adresse: %d", chaine, chaine);
  29. }
  30.  
  31.  
  32.