STR1

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include<iostream.

h>
#include<conio.h>
#include<stdio.h>
copy(char *a,char *b)
{ while(*a++=*b++);
// while(*b)
// {*a++=*b++;} *a='\0';
}
concatenate(char *c,char *d,char *e)
{ int i=0,j=0;
while(*c)
{ *(e++)=*(c++);} j++;
// while(*e++=*d++);
while(*d)
{ *(e++)=*(d++);}
*(e)='\0';
}
compare(char *f,char *g)
{ while(*f==*g)
{ if(*f='\0')
return 0;
f++;g++;
} return (*f-*g);
}
remove_space(char *h,char *j)
{ while(*h)
{ if(*h!=' ')
*j++=*h;
*h++;
}*j='\0';
}
void main()
{ int i=0,com;clrscr();
char ch,*str1,*str2,*str3,*str4,*str5;
printf("str1 : ");
while((ch=getchar())!='\n')
{ *(str1+i++)=ch;
} *(str1+i)='\0';
copy(str2,str1);
printf("\nstr3 : ");
while((ch=getchar())!='\n')
{ *(str3+i++)=ch;
} *(str3+i)='\0';
concatenate(str2,str3,str4);
com=compare(str1,str3);
remove_space(str1,str5);
printf("\nstr2 (copy of str1) : ");

while(*str2)
printf("%c",*str2++);
printf("\nstr1 + str3 : ");
while(*str4)
printf("%c",*str4++);
printf("\nstr1-str3 = %d",com);
printf("\nstr1 without space : ");
while(*str5)
printf("%c",*str5++);
getch();
}

You might also like