#include <iostream.h>
#include <string.h>
int main()
{
char x[] = "Happy Birthday to You";
char y[ 25 ], z[ 15 ];
cout << "The string in array x is: " << x
<< "\nThe string in array y is: " << strcpy( y, x )
<< '\n';
strncpy( z, x, 14 ); // does not copy null character
z[ 14 ] = '\0';
cout << "The string in array z is: " << z << endl;
return 0;
}
OUTPUT:
The string in array x is: Happy Birthday to You
The string in array y is: Happy Birthday to You
The string in array z is: Happy Birthday
No comments:
Post a Comment