Count The Words In A String | C Programming Example

Count The Words In A String | C Programming Example

Portfolio Courses

2 года назад

12,085 Просмотров

An example of how to count the number of words in a string with C. Source code: https://github.com/portfoliocourses/c-example-code/blob/main/count_words.c. Check out https://www.portfoliocourses.com to build a portfolio that will impress employers!
Ссылки и html тэги не поддерживаются


Комментарии:

@gnesha5904
@gnesha5904 - 21.04.2023 12:51

I’m having a strange problem where my word count function is counting trailing white spaces as a word

For example using strtok I pass a string that would say “hello my name is \nNice to meet you” (assume the \n is an actually enter key on a .txt file and the trailing spaces r at the end of the line) my word count would return 5 when there’s only 4 words. Any help?

Ответить
@SketchupGuru
@SketchupGuru - 02.01.2023 16:59

Getting back to learning after a long break!!
I'm a slow learner but learning with each video

Ответить
@jor1994
@jor1994 - 06.10.2022 22:19

What if I am trying to count the words from a string already obtained from the user via get_string?
I am getting confused with what the "char s[] = ?" would equal in this scenario.
Video was super helpful at explaining the why behind all your lines, thank you!

Ответить
@gangsterschnitzel9716
@gangsterschnitzel9716 - 02.09.2022 09:45

Thank you, it helps a lot !

Ответить
@Mr_wisk
@Mr_wisk - 01.09.2022 14:59

does this work with non predefined words? like if i make the user input a text?

Ответить
@Tad4546
@Tad4546 - 22.08.2022 14:18

Damn, stuff's well explained, thanks :)

Ответить
@BlackCat-fx9kb
@BlackCat-fx9kb - 12.07.2022 19:14

Do you have a video covering how to save a full sentence input and then separate each word into an array?

Ответить
@animeproz6780
@animeproz6780 - 15.11.2021 20:41

How if there is a nonwords at the beginning of the string?

Ответить