Directory: | ./ |
---|---|
File: | s21_memcmp.c |
Date: | 2025-07-13 17:59:14 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 7 | 7 | 100.0% |
Branches: | 4 | 4 | 100.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "s21_string.h" | ||
2 | |||
3 | 5 | int s21_memcmp(const void *str1, const void *str2, s21_size_t n) { | |
4 | 5 | const unsigned char *s1 = (const unsigned char *)str1; | |
5 | 5 | const unsigned char *s2 = (const unsigned char *)str2; | |
6 | |||
7 | 5 | int dif = 0; | |
8 |
4/4✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 1 times.
|
17 | for (s21_size_t i = 0; i < n && dif == 0; i++) { |
9 | 12 | dif = s1[i] - s2[i]; | |
10 | } | ||
11 | |||
12 | 5 | return dif; | |
13 | } | ||
14 |