Wednesday, 10 July 2019

write a programe to copy one string into another and count the number of characters copied

#include<stdio.h>
main()
{
    char string1[80],string2[80];
    int i;
    printf("Enter a string:");
    scanf("%s",string2);
    for(i=0;string2[i];i++)
        string1[i]=string2[i];
    string1[i]='\0';
    printf("%s\n",string1);
    printf("The number of character=%d\n",i);
}

No comments:

Post a Comment