Mega Code Archive
Categories
/
C
/
Code Snippets
Use malloc to allocate memory
#include
#include
int main(void) { char *j; j = malloc(80); if( !j ) { printf("Memory Allocation Failed"); exit(1); } printf("Enter a string: "); gets( j ); printf( j ); free( j ); return 0; }