C examples for Memory:malloc
Using malloc() to create and read strings from standard input
#include <stdio.h> #include <stdlib.h> int main()// w w w . ja v a 2 s .c o m { char *name; name = (char *) malloc(80*sizeof(char)); if ( name != NULL ) { printf("\nEnter your name: "); gets_s(name,80); printf("\nHi %s\n", name); } }