Wednesday, August 08, 2012

Program to copy one string to another string by using pointers

Program to copy one string to another string by using pointers
Copy string Output

void main(void) {
  char sta[]="Pakistan";
  char stb[15];
  char *sa=sta;
  char *sb=stb;
  while(*sa!='\0') {
  *sb=*sa;
  *sa++;
  *sb++;
  }
  *sb='\0';
  cout<<stb<<endl;
}