Extra 5% OFF Use Code: OL05
Free Shipping over ₹999

Copy string without using strcpy()

#include <stdio.h>
int main() {
    char arr1[100], arr2[100], i;
    printf("Enter string arr1: ");
    fgets(arr1, sizeof(arr1), stdin);

    for (i = 0; arr1[i] != '\0'; ++i) {
        arr2[i] = arr1[i];
    }

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

    Leave a Reply

    Your email address will not be published.

    Need Help?