String: strncpy(dest, source, n)
Copy specified number of characters from one string to another string using library function
#include<string.h>
main()
{
char s[60],
d[60]="\0";
printf("\nSource
string:\t");
gets(s);
strncpy(d,
s, 5);
printf("\nDestination
string: %s", d);
}
Output:
Source
string: Hii How Are you
Destination
string: Hii H
No comments:
Post a Comment