How to copy or concatenate two char*
How do you concatenate or copy char* together? char* totalLine; const char* line1 = "hello"; const char* line2 = "world"; strcpy(totalLine,line1); strcat(totalLine,line2); This code produces an error! segmentation fault I would guess that i would need to allocate memory to totalLine? Another question is that does the following copy memory or copy data? char* totalLine; const char* line1 = "hello"; totalLine = line1; Thanks in advance! :) I would guess that i would need to allocate memory to totalLine? Yes, you guessed correctly. totalLine is an uninitialized pointer, so those strcpy calls are