参考stdlib库

动态分配内存

escription = (char *)malloc( 200 * sizeof(char) );

if( description == NULL )
{
	fprintf(stderr, "Error - unable to allocate required memory\\\\n");
}
else
{
	strcpy( description, "Zara ali a DPS student in class 10th");
}

重新调整内存的大小和释放内存

当程序退出时,操作系统会自动释放所有分配给程序的内存,但我们在不需要内存时都应该调用函数 free() 来释放内存或通过调用函数 realloc() 来增加或减少已分配的内存块的大小。 description = (char *) realloc( description, 100 * sizeof(char) );free(description);