| Directory: | ./ |
|---|---|
| File: | s21_strrchr.c |
| Date: | 2025-11-01 23:04:41 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 9 | 9 | 100.0% |
| Branches: | 6 | 6 | 100.0% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "s21_string.h" | ||
| 2 | |||
| 3 | 5 | char* s21_strrchr(const char* str, int c) { | |
| 4 | 5 | const char* p = str; | |
| 5 | 5 | char* result = S21_NULL; | |
| 6 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 5 times.
|
14 | for (; *p != '\0'; p++) { |
| 7 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7 times.
|
9 | if (*p == c) { |
| 8 | 2 | result = (char*)p; | |
| 9 | } | ||
| 10 | } | ||
| 11 | |||
| 12 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
|
5 | if (c == 0) { |
| 13 | 2 | result = (char*)p; | |
| 14 | } | ||
| 15 | |||
| 16 | 5 | return result; | |
| 17 | } | ||
| 18 |