If you want, we could use Alloca here. #include<alloca.h> then replace calloc(1,256) with alloca(256) //doesn't zero initalize, but since strcat adds the terminating null character, you don't need to do that. With alloca we won't have to free the memory because it lives on the stack.