-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstring-operations.c
42 lines (38 loc) · 920 Bytes
/
string-operations.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
38
39
40
41
42
//string compare, concatenate, length
#include <stdio.h>
#include <stdlib.h>
void stringlenghth(char a[100],char b[100]);
void stringconcatenate(char a[100],char b[100]);
void stringcompare(char a[100],char b[100]);
void main()
{
char p [100],q[100];
printf("Enter the first string\n");
gets(p);
printf("Enter the second string\n");
gets(q);
stringlenghth(p,q);
stringconcatenate(p,q);
stringcompare(p,q);
}
void stringlenghth(char a[100],char b[100])
{
int len1,len2;
len1=strlen(a);
len2=strlen(b);
printf("The first string length is %d \n and second is %d\n",len1,len2);
}
void stringconcatenate(char a[100],char b[100])
{
printf("The concatenated string is %s\n",strcat(a,b));
}
void stringcompare(char a[100],char b[100])
{
if(strcmp(a,b)==0)
{
printf("Strings are equal\n");
}
else{
printf("Strings are not equal\n");
}
}