diff --git a/_get_comment_position.c b/_get_comment_position.c new file mode 100644 index 0000000..6afa55d --- /dev/null +++ b/_get_comment_position.c @@ -0,0 +1,24 @@ +#include "shell.h" + +/** + * _get_comment_position - function that returns the + * position of the # or the length of the line + * if # not found + * + * @line: string to lookup in + * Return: (integer) position of the # + * or the length if not found + */ +int _get_comment_position(const char *line) +{ + int i; + + for (i = 0; line[i] != '\0'; i++) + { + if (line[i] == '#') + { + return (i); + } + } + return (i); +} diff --git a/shell.h b/shell.h index de0274f..333bdc6 100644 --- a/shell.h +++ b/shell.h @@ -64,4 +64,5 @@ char *_get_value(const map_t *map, const char *key); void _clear_entry(void *data); void _clear_map(map_t *map); list_t *_get_keys(const map_t *map); +int _get_comment_position(const char *line); #endif