forked from anxkhn/CP-SAMPLE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
27.c
37 lines (32 loc) · 839 Bytes
/
27.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<stdio.h>
#include<string.h>
void main()
{
char x,a[100],b[100],c[100];
int l,k,z;
printf("Enter string A: ");
gets(a);
printf("Enter string B: ");
gets(b);
//LENGTH
l=strlen(a);
k=strlen(b);
printf("The lengths of A and B are %d and %d\n",l,k);
//COMPARE ASCII VALUES
if(strcmp(a,b)==0)
printf("Strings are equal.\n");
else if(strcmp(a,b)>0)
printf("A is bigger.\n");
else
printf("B is greater.\n");
//COPY COPIES A INTO C
strcpy(c,a);
printf("The new string C is %s\n",c);
//CONCATNATE ADDS B INTO A
strcat(a,b);
printf("The concatnated string A and B is %s",a);
//CONCATNATE ADDS B INTO A with option of number of characters.
printf("Enter the length you want to CONCATNATE");
scanf("%d", &z);
strncpy(a,b,z)
}