26 lines
1.1 KiB
C
26 lines
1.1 KiB
C
/// @file
|
|
/// @brief Task3: structure and function declarations
|
|
|
|
#pragma once
|
|
|
|
/// @brief todo
|
|
struct StringStats {
|
|
unsigned int lines;
|
|
unsigned int words;
|
|
};
|
|
|
|
/// @brief Counts the number of lines and words in a null-terminated multiline string 'str':
|
|
/// Line:
|
|
/// - a line always ends with a newline ('\n') character
|
|
/// - 'str' is always terminated by a empty last line (terminated with the null character)
|
|
/// - this empty last line is not reflected in the number of lines (e.g. an empty string has zero lines)
|
|
/// Word:
|
|
/// - a word is here defined as each continuous sequence of non-whitespace characters
|
|
/// (e.g. also punctuation can be part of a word)
|
|
/// - whitespace characters are identified using 'isspace' from the 'ctype.h' standard library header
|
|
/// @param str Pointer to a null-terminated character range representing a multiline string:
|
|
/// - 'str' is always terminated by a empty last line
|
|
/// - 'str' is always null-terminated
|
|
/// @return Structure holding the number of lines and words counted in 'str'
|
|
struct StringStats task3_stringstats(const char* str);
|