You are on page 1of 4

#include<string.

h>
#include<conio.h>
#include<stdio.h>
void main()
{ char s1[20], s2[20], s3[50];
int x, l1, l2, l3;
clrscr();
printf("\n\nEnter two strings \n");
scanf("%s %s", s1, s2);
strcat(s1, s2);
/* comparing s1 and s2 */
printf("\n STRING COMPARE \n");
printf("\n -------------- \n");
x=strcmp(s1,s2);
if(x != 0)
printf("\n\nStrings are equal\n \n");
else

printf("\n\nStrings are not equal \n");


printf("\n STRING CONCATENATION \n");
printf("\n -------------------- \n");
printf("\n Concatenated String : %s\n\n",s1);
printf("\n STRING COPY \n");
printf("\n ----------- \n");
strcpy(s3, s2);
printf("\ncopied string of s2 to s3 : %s\n",s3);
/* Finding length of strings */
l1 = strlen(s1);
l2 = strlen(s2);
l3 = strlen(s3);
printf("\n STRING LENGTH \n");
printf("\n ------------- \n");
printf("\ns1 = %s\t length = %d characters\n", s1, l1);
printf("s2 = %s\t length = %d characters\n", s2, l2);
printf("s3 = %s\t length = %d characters\n", s3, l3);
printf("\n STRING REVERSE \n");
printf("\n -------------- \n");
strrev(s1);
printf("\nReversed String of s1: %s",s1);
strrev(s2);
printf("\nReversed String of s2: %s",s2);
strrev(s3);
printf("\nReversed String of s3: %s",s3);
}

getch();

#include<stdio.h>

void main()
{
char source[10],target[10],ch;
FILE *f1,*f2;
puts("enter the source file name:");
gets(source);
puts("enter the target file name:");
gets(target);
f1=fopen(source,"r");
f2=fopen(target,"w");
if(f1==0&f2==0)
{
printf("f open error");
exit(0);
}
while((ch=getc(f1))>0)
putc(ch,f2);
fclose(f1);
fclose(f2);
}

You might also like