Program to illustrates strcpy ( ) function


#include <iostream.h>
#include <conio.h>
#include <string.h>          
void main( )
{
char s1[20 ] = "Hello";
char s2[ ] = "Hi";
cout<<"Before strcpy (s1,s2) : \n";
cout<<" \t s1 = [ " <<s1 << "] , length = " <<strlen(s1)<<endl;
cout<<" \t s2 = [ " <<s2 << "] , length = " <<strlen(s2)<<endl;
strcpy(s1,s2) ;
cout<<"After strcpy (s1,s2) : \n";
cout<<" \t s1 = [ " <<s1 << "] , length = " <<strlen(s1)<<endl;
cout<<" \t s2 = [ " <<s2 << "] , length = " <<strlen(s2)<<endl;
getch( );               
}

0 comments:

Post a Comment

 
 
 
 


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