#include<stdio.h>
#include<conio.h>
int length(char *);
char cat(char *,char *,char *);
void main()
{
int len;
char a[100],b[100],c[100];
clrscr();
printf("Enter the string \n");
gets(a);
len=length(a);
printf("the length of the string is %d",len);
printf("\nEnter the first string");
gets(a);
printf("\nEnter the second string");
gets(b);
cat(a,b,c);
printf("\nThe resultant string is %s",c);
getch();
}
int length(char *x)
{
char *y;
y=x;
while(*x!='\0')
x++;
return(x-y);
}
char cat(char *x,char *y,char *z)
{
while(*x!='\0')
*z++=*x++;
while(*y!='\0')
*z++=*y++;
*z='\0';
return 0;
}
#include<conio.h>
int length(char *);
char cat(char *,char *,char *);
void main()
{
int len;
char a[100],b[100],c[100];
clrscr();
printf("Enter the string \n");
gets(a);
len=length(a);
printf("the length of the string is %d",len);
printf("\nEnter the first string");
gets(a);
printf("\nEnter the second string");
gets(b);
cat(a,b,c);
printf("\nThe resultant string is %s",c);
getch();
}
int length(char *x)
{
char *y;
y=x;
while(*x!='\0')
x++;
return(x-y);
}
char cat(char *x,char *y,char *z)
{
while(*x!='\0')
*z++=*x++;
while(*y!='\0')
*z++=*y++;
*z='\0';
return 0;
}
No comments:
Post a Comment