By using pointers, and dynamic memory allocation – we have to declare a character pointer, allocate memory at run time in C language.
#define MAX 100
//declaring character pointer
//allocating memory at run time
buffer = (char*)malloc(MAX*sizeof(char));
printf("Error in allocating memory!!!\n");
//assign any string
printf("buffer: %s", buffer);
buffer: Hello, World
total answers (1)
start bookmarking useful questions and collections and save it into your
own study-lists, login now to start creating your own collections.