From c654697e4d1a99c957ec859f4c929631745ea374 Mon Sep 17 00:00:00 2001 From: Hamza Naitsi <93101878+h01nait@users.noreply.github.com> Date: Sun, 21 May 2023 20:23:40 +0100 Subject: [PATCH] Comment position (#6) * linkedlist_finished * fineshed_hashtable * added missing function from to shell.h * modification to shell.h * comment_position * modification to shell.h --- _get_comment_position.c | 24 ++++++++++++++++++++++++ shell.h | 1 + 2 files changed, 25 insertions(+) create mode 100644 _get_comment_position.c 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