C语言库free()函数

#include stdio.h#include stdlib.h#include string.hint main () {char *str;/* Initial memory allocation */

编程学习网为您整理以下代码实例,主要实现:C语言库free()函数,希望可以帮到各位朋友。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main () {
   char *str;

   /* Initial memory allocation */
   str = (char *) malloc(15);
   strcpy(str, "yiibai");
   printf("String = %s,  Address = %u\n", str, str);

   /* Reallocating memory */
   str = (char *) realloc(str, 25);
   strcat(str, ".com");
   printf("String = %s,  Address = %u\n", str, str);

   /* Deallocate allocated memory */
   free(str);

   return(0);
}
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐