paleofetch

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 5084173d502fe680c2962a642511173144cc8fde
parent 4007c41d4ecd28dcef36af1a54f2c63389c19b2c
Author: Sridaran Thoniyil <sri7thon@gmail.com>
Date:   Fri,  8 May 2020 14:47:28 -0400

Add remove_newline function that returns length of string


Diffstat:
Mpaleofetch.c | 11+++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)

diff --git a/paleofetch.c b/paleofetch.c @@ -59,6 +59,17 @@ void remove_newline(char *s) { } /* + * Replaces the first newline character with null terminator + * and returns the length of the string + */ +int remove_newline_get_length(char *s) { + int i; + for (i = 0; *s != '\0' && *s != '\n'; s++, i++); + *s = '\0'; + return i; +} + +/* * Cleans up repeated spaces in a string * Trim spaces at the front of a string */