Program which concatenates a string to the left of a given string


# include <iostream.h>
# include<conio.h>
#include<string.h>
void main( )
{
char *s1="Good", *s2= "Day", *s3;

 s3 = s2 + (strlen(s2)-1);   // s3 points to last character of s2
while(*s2 != '\0')
{
         *--s1=*s3--;
         s2++;
}
    cout<<s1;                        //print concatenated string
    getch( );
}

0 comments:

Post a Comment

 
 
 
 


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