equal(3C)
_________________________________________________________________
equal function
Determine if two strings are equal.
_________________________________________________________________
Calling Sequence
#include <string.h>
char *string1, *string2;
int equal(), strequal;
strequal = equal(string1, string2);
where string1 and string2 are pointers to strings
Description
The equal function determines whether or not the two strings
pointed to by string1 and string2 are equal. Note that uppercase
and lowercase alphabetic characters have different values; that
is, A does not equal a.
Returns
If the two strings are not equal, the function returns 0;
otherwise, it returns 1.
Related Functions
See also the any, strchr, strnchr, strcmp, strncmp, strpbrk, and
verify functions.
Example
/* Program test for the equal() function */
#include <stdio.h>
#include <string.h>
int result, equal(), i = 1;
main(argc, argv)
int argc;
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
equal(3C)
char *argv[];
{
while (i < argc) {
result = equal(argv[i], argv[i + 1]);
printf("%d - strings are %s equal.\n", result,
(result == 0) ? "not" : "");
i += 2;
}
}
If you call the program test with the following argument pairs
abc xyz
abc ABC
abc ab
ab abc
abc abc
you generate the output
0 - strings are not equal.
0 - strings are not equal.
0 - strings are not equal.
0 - strings are not equal.
1 - strings are equal.
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)