Program to Copy a String


#include <iostream.h>
#include <conio.h>
#include<stdio.h>
void main ( )
{
        int i ;
        char sentence[40] , copy[40] ;
        cout<<"Enter any string :" ;
        gets (sentence) ;
        i = 0 ;
        for (i=0 ; i<40 ; i++)
            copy[i] = 0 ;
        i = 0 ;
        while (sentence[i] != '\0')
        {
            copy[i] = sentence[i] ;
            i++ ;
        }
        cout<<"\nThe copied string is : " ;
        puts (copy) ;
        getch ( ) ;
    }

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|