// Example 7.16, page 201 // Schaum's Outline of Programming with C++ by John R. Hubbard // Copyright McGraw-Hill, 1996 using namespace std; #include #include // Test-driver for the strncpy() function: int main() { char s1[] = "ABCDEFG"; char s2[] = "XYZ"; cout << "Before strncpy(s1,s2,2):\n"; cout << "\ts1 = [" << s1 << "], length = " << strlen(s1) << endl; //cout << "\ts2 = [" << s2 << "], length = " << strlen(s2) << endl; //strncpy(s1,s2,2); strncpy(s1,s2,4); //RS: che succede in questo caso?: cout << "After strncpy(s1,s2,2):\n"; cout << "\ts1 = [" << s1 << "], length = " << strlen(s1) << endl; cout << "\ts2 = [" << s2 << "], length = " << strlen(s2) << endl; return 0; }