42 lines
1.3 KiB
C
42 lines
1.3 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* :::::::: */
|
|
/* pointer_lines.c :+: :+: */
|
|
/* +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
|
/* +#+ */
|
|
/* Created: 2025/04/22 13:03:24 by whaffman #+# #+# */
|
|
/* Updated: 2025/05/07 11:48:40 by whaffman ######## odam.nl */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <stdlib.h>
|
|
#include "cub3d.h"
|
|
|
|
char **pointer_lines(char *buffer, char c)
|
|
{
|
|
char **lines;
|
|
size_t count;
|
|
size_t i;
|
|
|
|
count = count_chars(buffer, c) + 1;
|
|
lines = malloc(sizeof(char *) * (count + 1));
|
|
if (!lines)
|
|
return (NULL);
|
|
lines[0] = buffer;
|
|
i = 1;
|
|
while (i < count)
|
|
{
|
|
lines[i] = ft_strchr(buffer, c);
|
|
if (lines[i])
|
|
{
|
|
*lines[i] = '\0';
|
|
lines[i] += 1;
|
|
buffer = lines[i];
|
|
}
|
|
i++;
|
|
}
|
|
lines[i] = NULL;
|
|
return (lines);
|
|
}
|