C Program to Copy String to Another String

C Program to Copy String to Another String

Write C Program to Copy String to Another String

// C Program to Copy String to Another String

#include <stdio.h>
#include <string.h>

int main()
{
	char S1[] = "CodeCrucks";
    printf("String :--> : %s", S1);

	char S2[50];
	int i = 0;

//	strcpy(ch,str);     // Using inbuilt function

    // Doing manually
	while(S1[i] != '\0')
	{
		S2[i] = S1[i];
		i++;
	}
	S2[i] = '\0';

    printf("\nCopied String :--> : %s", S2);

	return 0;
}

Output:

String :--> : CodeCrucks
Copied String :--> : CodeCrucks