Mega Code Archive

 
Categories / C / Code Snippets
 

Copies up to count characters from str2 to str1

//Declaration: char *strncpy(char *str1, const char *str2, size_t count); //Return: returns a pointer to str1. #include<stdio.h> #include<string.h> int main(void){ char str1[148], str2[100]; gets(str1); strncpy(str2, str1, 89); printf("%s",str2); }