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