C++ copy a part of a char array to another char array

c++

Solution

If you really want to, use strcat (if you don't use strings, you should be ok with the C-functions anyway):

const char * first_string = "Every morning I";
const char * second_string = "go to the library, eat breakfast, swim.";
char final_string[80]; // make sure it's big enough - I haven't counted ;-)

strcpy(final_string, first_string);     // copy to destination
strcat(final_string, second_string+18); // append part of the second string

Problem

I'm trying to copy only a portion of a string (or char *) into another string (or another char *) ``` char * first_string = "Every morning I" char * second_string = "go to the library, eat breakfast, swim." char * final_string; ``` I would like to copy part of the second_string into the first_string. For Example: Every morning I eat breakfast. What is the function that allows you to copy only a portion of a string, starting from a specific point in the string? Note: I don't want to use string variables, but char *, or even char arrays, if possible.

Original source