Friday, November 23, 2012

WRITE A C PROGRAM TO COPY THE CONTENTS OF ONE STRING TO ANOTHER.


/*   WRITE A C PROGRAM TO COPY THE CONTENTS OF ONE STRING TO
     ANOTHER.
*/
#include<stdio.h>
#include<conio.h>

#define MAX 50

void main()
{
            char str1[MAX],str2[MAX];
            int i,len;

            clrscr();
            printf("Enter a string : ");
            gets(str1);

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

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

            printf("The string is : \"%s\" ",str2);
            getch();
}

/*
            =====OUT PUT=====

            Enter a string : KAUNDINYA
            The string is : "KAUNDINYA"

*/


0 comments:

Post a Comment