Allocate memory and save string in c
char *test = (char*) malloc(12*sizeof(char)); +-+-+-+-+-+-+-+-+-+-+-+-+ test—>|x|x|x|x|x|x|x|x|x|x|x|x| (uninitialized memory, heap) +-+-+-+-+-+-+-+-+-+-+-+-+ test = “testingonly”; +-+-+-+-+-+-+-+-+-+-+-+-+ test + |x|x|x|x|x|x|x|x|x|x|x|x| | +-+-+-+-+-+-+-+-+-+-+-+-+ | +-+-+-+-+-+-+-+-+-+-+-+-+ +->|t|e|s|t|i|n|g|o|n|l|y|0| +-+-+-+-+-+-+-+-+-+-+-+-+ free(test); // error, because test is no longer pointing to allocated space. Instead of changing the pointer test, you need to copy the string “testingonly” into the allocated place using e.g. … Read more