From 5096a42f46cad7a4673dae313c033c1f39bcffb3 Mon Sep 17 00:00:00 2001 From: KleptsovKD Date: Wed, 5 Feb 2025 01:01:01 +0300 Subject: [PATCH] Added a pointer and a loop skipping delimiters --- lab04.1/main.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lab04.1/main.cpp b/lab04.1/main.cpp index 8b4fe99..7acaf0e 100644 --- a/lab04.1/main.cpp +++ b/lab04.1/main.cpp @@ -7,9 +7,21 @@ const char* SEPARATORS = " \r\n,.!?:;()-"; int main() { char text[MAX_SIZE] = {0}; - std::cout << "Enter the line: "; fgets(text, MAX_SIZE, stdin); + const char* start = text; + + while (true) { + + size_t separator_count = strspn(start, SEPARATORS); + start += separator_count; + + if (start[0] == '\0') + { + break; + } + } + return 0; }