-
Notifications
You must be signed in to change notification settings - Fork 16
/
15.c
50 lines (42 loc) · 1.01 KB
/
15.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
43
44
45
46
47
48
49
50
#include <stdio.h>
void copy_string(char *one, char *two)
{
int i;
for (i=0; one[i] != '\0'; i++)
two[i] = one[i];
two[i] = '\0';
return;
}
void compare_string(char *one, char *two)
{
int i;
for (i=0; one[i] != '\0'; i++)
if (one[i] != two[i])
break;
if (one[i] == '\0' && two[i] == '\0')
printf("Strings are equal\n");
else
printf("Strings are not equal\n");
return;
}
void concat_string(char *one, char *two)
{
int i, j;
for (i=0; one[i] != '\0'; i++);
for (j=0; two[j] != '\0'; j++)
one[i+j] = two[j];
one[i+j] = '\0';
return;
}
int main()
{
char string_one[100], string_two[200];
printf("Enter your string: ");
fgets(string_one, 100, stdin);
copy_string(string_one, string_two);
printf("Your second string is: %s", string_two);
compare_string(string_one, string_two);
concat_string(string_one, string_two);
printf("Your concatenated string is: %s", string_one);
return 0;
}