Using memcpy
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
char s1[ 17 ], s2[] = "Copy this string";
memcpy( s1, s2, 17 );
cout << "After s2 is copied into s1 with memcpy,\n"
<< "s1 contains \"" << s1 << '\"' << endl;
return 0;
}
Related examples in the same category