Thursday 6 September 2012

/* --- Program on String Copy --- */


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

    clrscr();
    gotoxy(15,2);
    printf("Program to Copy a String\n");
    gotoxy(5,5);
    printf("Enter any String : ");
    gets(str1);
    gotoxy(5,7);

/*    Copying procedure    */

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

    str2[i]='\0';    /* Assigning a Null to end */

    printf("String is copied...\t");
    puts(str2);
    getch();
}

No comments:

Post a Comment