From 129a10d1ee57a047ae9a3084e175de1e7daf6ffe Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sun, 29 Jun 2025 20:48:41 -0400 Subject: Fix justify behavior --- include/word.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 include/word.h (limited to 'include/word.h') diff --git a/include/word.h b/include/word.h new file mode 100644 index 0000000..b5d94b5 --- /dev/null +++ b/include/word.h @@ -0,0 +1,28 @@ +#ifndef WORD_H +#define WORD_H + +#include + +#define READ_WORD_ERR_READ -1 +#define READ_WORD_ERR_EOF 0 +#define READ_WORD_SUCCESS 1 + +/** + * Read in a word from a file up to size length. + * + * If there is any leading whitespace, it will be discarded + * before starting to read in a word. + * + * @param[in] fp The file to read a word from. + * @param[out] word The word that was read as a null-terminated string. + * @param[in] length The length of the word to read in. + * + * @note `length` should be the number of characters you'd + * like to read in plus one to take into account the + * null terminator. + * + * @returns < 0 on read error; 0 on EOF; > 0 on success. + */ +int read_word(FILE *fp, char *word, size_t length); + +#endif -- cgit v1.2.3