mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
29 lines
1.2 KiB
C
29 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strchridx.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2025/02/14 14:02:34 by khais #+# #+# */
|
|
/* Updated: 2025/02/14 15:12:01 by khais ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <stddef.h>
|
|
|
|
/*
|
|
** return the index of the character c in the string s, or 0 if s is null, or
|
|
** length of s if c is not found.
|
|
*/
|
|
size_t ft_strchridx(const char *s, char c)
|
|
{
|
|
size_t i;
|
|
|
|
if (s == NULL)
|
|
return (0);
|
|
i = 0;
|
|
while (s[i] != c && s[i] != '\0')
|
|
i++;
|
|
return (i);
|
|
}
|