-
Notifications
You must be signed in to change notification settings - Fork 0
/
str_fun.c
66 lines (53 loc) · 1.55 KB
/
str_fun.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include<stdio.h>
#include<string.h>
// strcat();
// Used to concatenate the source string to the end of the target string .
// int main(){
// char s[]="Hello";
// char t[]="World";
// strcat(s,t);
// printf("string = %s", s);
// return 0;
// }
// strlen();
// This function is used to count the number of characters present in a string
// int main(){
// char s[]= "Hello" ;
// int len=strlen(s);
// printf("Length = %d", len);
// return 0;
// }
// strcpy();
// This function is used to copy the content of one string into other. Expects two parameter . First base address of source string then the base address of the targeted string
// int main() {
// char s[]="Hello Their";
// char t[50];
// strcpy(t,s);
// printf("Source string = %s\n", s);
// printf("Targeted string = %s", t);
// }
// strcmp();
// Used to compare twi strings to find out whether they are same or different
// int main() {
// char s[]= "Hello";
// char t[]="World";
// int cmp=strcmp(s,t);
// printf("Comparison result = %d",cmp);
// }
// strrev();
// This function is used to return the reverse of the string
// int main() {
// char s[]="Hello";
// printf("Reversed string=%s", strrev(s));
// return 0;
// }
// strcmp();
// Used To compare two given strings
int main() {
char* first_str="Hello";
char* second_str="Hello";
printf("First String= %s\n", first_str);
printf("Second String=%s\n", second_str);
printf("Return value of strcmp(): %d\n", strcmp(first_str, second_str));
return 0;
}