#include #include #include main() { char * str; str = (char*)malloc(51 * sizeof(char)); /* (not forgetting the nul) */ if (str == NULL) { fprintf(stderr, "ERROR: no space left.\n"); exit(EXIT_FAILURE); } printf("Allocation succeeded!\n"); strcpy(str, "Up to 50 characters"); /* Use str like any char array */ return 0; }