C++字符串函数

#include <iostream>
#include <cstring>

using namespace std;

int main () {
   char str1[10] = Hello;
   char str2[10] = World;
   char str3[10];
   int  len ;

   // copy str1 into str3
   strcpy( str3, str1);
   cout << strcpy( str3, str1) :  << str3 << endl;

   // concatenates str1 and str2
   strcat( str1, str2);
   cout << strcat( str1, str2):  << str1 << endl;

   // total lenghth of str1 after concatenation
   len = strlen(str1);
   cout << strlen(str1) :  << len << endl;

   return 0;
}

相关文章

#include <iostream> using namespace std; int mai...
#include <iostream> using namespace std; int mai...
// #include <iostream> using namespace std; int...
#include <iostream> #include <string> using...
#include <iostream> #include <cstring> usin...
#include <iostream> using namespace std; int mai...