C program to copy one string into another string and count the number of characters copied

				
					#include<stdio.h> 
#include<conio.h> 
void main() 
{ 
char strng1[50], strng2[50];
int i; 
printf(“Enter a string\n”);
scanf(“%s", strng2); 
for(i=0; strng2[i]!=’\0’; i++) 
strng1[i]=strng2[i]; 
strng1[i]=’\0’; 
printf(“\n”); 
printf(“after copy:%s\n”, strng1); 
printf(“number of charcters copied = %d\n”, i);
}
				
			
Output:
Enter a string
Man
after copy:Man
Number of characters=3

Leave a Reply