-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyze_middle_row.c
39 lines (36 loc) · 1.36 KB
/
analyze_middle_row.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* ************************************************************************** */
/* */
/* :::::::: */
/* analyze_middle_row.c :+: :+: */
/* +:+ */
/* By: kstallen <[email protected]> +#+ */
/* +#+ */
/* Created: 2019/08/25 21:01:56 by kstallen #+# #+# */
/* Updated: 2019/08/25 21:37:57 by kstallen ######## odam.nl */
/* */
/* ************************************************************************** */
#include "header.h"
char char_middle_row(char *str, int x, int y)
{
int h;
int i;
char result;
i = 0;
h = y;
result = 0;
while (y > 1)
{
if (str[i] == '\n')
{
if (i == x)
result = str[i + 1];
if (str[i + 1] != result && y > 2)
return ('x');
if (str[i - 1] != result && y < h)
return ('x');
y--;
}
i++;
}
return (result);
}