Follow Us

LightBlog

Breaking

Tuesday, February 28, 2017

String copy without using strcpy in c ?


String copy without using strcpy in c ?

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

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

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

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

    return 0;
}

No comments:

Post a Comment