Your IP : 216.73.216.40


Current Path : /var/www/html/venkat/old/old/
Upload File :
Current File : /var/www/html/venkat/old/old/lit2015038_2.c

//Write a program to compare two strings and concatenate & print the first string if not matches. Use pointer variables.Do not use <string.h>
#include<stdio.h>
int main()
{
   char str1[100],str2[100],*p1,*p2;
   int i,j,len1,len2,x=1;
   gets(str1);
   gets(str2);
   p1=str1;
   p2=str2;
    
   while(*p1!='\0' || *p2!='\0'){
      if(*p1!=*p2){
          x=0;
      }
     p1++;
     p2++;
   }

   if(x==1){
     puts(str1);
   }
   else{
      p1=str1;
      p2=str2;
      while(*p1!='\0'){
        p1++;
      }
     
      while(*p2!='\0'){
        *p1=*p2;
        p1++;
        p2++;
      }

      *p1='\0';
   
      puts(str1);
   }

   return 0;

}