Mega Code Archive
Categories
/
C
/
String
Copy characters from one string to another
#include
#include
int main () { char str1[]= "Hi Hello and "; char str2[6]; strncpy (str2, str1, 5); str2[5] = '\0'; puts (str2); return 0; }