Use malloc to allocate memory
#include <stdio.h> #include <stdlib.h> int main(void) { char *p; p = malloc(80); if( !p ) { printf("Memory Allocation Failed"); exit(1); } printf("Enter a string: "); gets( p ); printf( p ); free( p ); return 0; }