Wednesday, August 08, 2012

Program to combine two strings by using pointers


void main(void){
  char sta[]="Hello";
  char stb[]="World";
  char stc[20];
  char *s=stc;
  char *ptr=sta;
  while(*ptr!='\0'){
  *s=*ptr; *s++; *ptr++;
  }
  *s=' '; *s++; ptr=stb;
  while(*ptr!='\0'){
  *s=*ptr; *s++; *ptr++;
  }
  *s='\0';
  cout<<stc<<endl;
}