Design a C program to copy only n characters from str2 to str1 and find length of str1
Answers
Answered by
0
Copy String Without Using strcpy()#include <stdio.h> int main() { char s1[100], s2[100], i; printf("Enter string s1: "); fgets(s1, sizeof(s1), stdin); for (i = 0; s1[i] != '\0'; ++i) { s2[i] = s1[i]; } s2[i] = '\0'; printf("String s2: %s", s2); return 0; }
Output
Enter string s1: Hey fellow programmer. String s2: Hey fellow programmer.
Similar questions
Math,
2 months ago
Computer Science,
2 months ago
Sociology,
2 months ago
Math,
5 months ago
India Languages,
5 months ago
English,
11 months ago
Art,
11 months ago