home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************************
- * CH14_05.C RΘallocation de mΘmoire *
- *********************************************************************/
-
- #include<stdio.h>
- #include<alloc.h>
- #include<string.h>
-
- main( void)
- {
- char *chaine;
-
- chaine= ( char*) calloc( 16u, sizeof( char) );
-
- printf("\n Le 1er contenu de \"chaine\" est: %s\n"
- " et son adresse: %d", chaine, chaine);
-
- strncpy( chaine, "Hello World!", 15u);
- /* C'est la premiΦre phrase prise comme exemple dans livre de
- Kernighan & Ritchie, les inventeurs du C.*/
-
- printf("\n Le 2Φme contenu de \"chaine\" est: %s\n"
- " et son adresse: %d", chaine, chaine);
-
- chaine= (char*) realloc( chaine, 120u);
-
- printf("\n Le dernier contenu de \"chaine\" est: %s\n"
- " et son adresse: %d", chaine, chaine);
- }
-
-
-