We can use string function
strncpy() to copy part strings.
Part of the second string is added to the first string.
We will use this and here is one example.
strcpy(destination_string, source_string, n);
The output of above code is here, ( first 5 chars of var1 variable is copied to var2 variable )
char var1="First one";
char var2="Second two";
- Source string is not affected
- Destination string is replaced by source string.