C Program to Copy String Without Using strcpy()


  Copy String Without Using strcpy()


#include <stdio.h>
int main()
{
    char str1[100], str2[100], i;

    printf("Enter string str1: ");
    scanf("%s",str1);

    for(i = 0; str1[i] != '\0'; ++i)
    {
        str2[i] = str1[i];
    }

    str2[i] = '\0';
    printf("String str2: %s", str2);

    return 0;
}




Output:-


Disqus Comments