memcmp
| Buffer Manipulation Functions |
Compares two memory buffers.
int memcmp( const void *s1, const void *s2, size_t n);
| s1 | The name of a buffer. |
| s2 | The name of a buffer. |
| n | The number of characters to search at the beginning of the buffer. |
Return Values
Returns the value indicating the relationship between the buffers:
| Return value | Description |
| <0 | buffer1 is less than buffer2 |
| 0 | buffer1 is the same as buffer2 |
| >0 | buffer1 is greater than buffer2 |
For memcmp details, refer to your C language documentation.
Example
The following example uses memcmp to compare two strings and checks if they are equal.
char* s1 = "access to shared transmission";
char* s2 = "access to transmission";
int rc;
rc = memcmp( s1, s2, strlen(s1));
if (rc > 0)
lr_output_message("`%s' is greater than '%s'", s1, s2);
else if (rc < 0)
lr_output_message("`%s' is less than '%s'", s1, s2);
else
lr_output_message("'%s' is the same as '%s'\n", s1, s2);
Example: Output:
'access to shared transmission' is less than 'access to transmission'

