Введите массив символов из 14 на с++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Введите массив символов из 14 на с++

Введите массив символов из 14 элементов, содержащий пробелы. Найдите самое длинное слово, выведите на экран это слово и его длину.

16th Dec 2021, 1:08 PM
Алина Конькова
1 Answer
0
If you don't intend to keep the original string, then you might wanna look at strtok() from <cstring> header. You use strlen() to verify each token's length and compare against a <max_length> variable to find the longest one. Reference: https://en.cppreference.com/w/cpp/string/byte/strtok https://en.cppreference.com/w/cpp/string/byte/strlen
18th Dec 2021, 3:50 PM
Ipang