C++: string append and <cstring> strncat compaed.

Objectives :

  • Using Keyword : string::append and strncat
    • C cstr library : strncat(ch1,ch2, 20)
    • C++ string class : str4.append(str3);
  • Function : string + operator
  • File Name : compare_string_append_strncat1.cpp
  • Code:compare_string_append_strncat1.txt
  • Testing Environment : Eclipse and Quincy

Step: 1 Create a source file.

Step: 2 Edit and save Source file


Step: 3 Runtime Views:

Also tested with Eclipse IDE, note str1=ch1, assignment did not complain.

Step: Brief Discussion: Appending string at the end of a target string with append function is easier than strncat(...) function of C/cstring. In C programming , characters can be concatenated with strcat  or strncat, the later enables you to specify the number of characters from the source string to be appended at the end of the destination string.

And you can't do it either