Copy a string to another string without using library function

Lets see how can we copy a source string to destination string without using library functions.

Code 

#include<stdio.h>

int main()
{
    char source[20],dest[20];
    int i;

    printf("\nEnter source string : ");
    gets(source);

    for(i=0;source[i]!='\0';i++)
        dest[i] = source[i];

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

    return 0;
}


O/P

No comments:

Post a Comment