-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe_strcmp.h
More file actions
64 lines (63 loc) · 1.57 KB
/
e_strcmp.h
File metadata and controls
64 lines (63 loc) · 1.57 KB
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
/*
Author : eightnoteight (Srinivas Devaki)
Date : Wed May 28
Time : 9:44:31 AM
e-mail : mr.eightnoteight [at] gmail [dot] com
website : http://eightnoteight.wordpress.com
ABSTRACT : The deafult strcmp() merely returns info
about which string is lexographically
greater, but e_strcmp() returns the
difference between the words where the
first char difference between the strings.
Description : If the returned integer is positive then
*p string is lexographically greater than *q.
If the returned integer is negative then
*p string is lexographically lesser than *q.
If the returned integer is 0 *p is identical
to *q.
If the returned integer is greater than 27
then the *q string is a substring of *p string.
If the returned integer is less than -27 then
the *p string is a substring of *q string.
*/
inline int e_strcmp(char const *p, char const *q)
{
while(*p)
{
if(*q=='\0')
return *p-*q;
if(*p > *q)
return *p-*q;
if(*p < *q)
return *p-*q;
p++;
q++;
}
if(*q)
return *p-*q;
return 0;
}
/*Default Implemantion*/
/*Default Implemantion*/
/*Default Implemantion*/
/*Default Implemantion*/
/*Default Implemantion*/
/*
inline int strcmp(char const *p, char const *q)
{
while(*p)
{
if (*q == '\0')
return 1;
if (*p > *q)
return 1;
if (*p < *q)
return -1;
p++;
q++;
}
if(*q)
return -1;
return 0;
}
*/