As RHuros states you should use malloc and free.
If I'm right and you want to do that across different functions you should take a look at this code:
#include "stdafx.h"
#include "stdlib.h"
#include "conio.h"
void reserve(void* &pchar)
{
pchar = malloc(10000);
printf("malloc ==> ");
}
void remove(void* &pchar)
{
free(pchar);
printf("free.\n");
}
int _tmain(int argc, _TCHAR* argv[])
{
void* pchar = NULL;
while (!_kbhit())
{
reserve(pchar);
remove(pchar);
}
return 0;
}
NOTE:
Keep in mind that this is not a good design... you should not do that as it would be hard to maintain in the future. It can be done and it will work anywhere, but it should not be done to avoid possible problems.
Hope this helps... :thumbsup: