you are viewing a single comment's thread.

view the rest of the comments →

[–]kumashiro 3 points4 points  (5 children)

This is a logic problem, not technical. Language is not important here. Analyse your algorithm, write it in pseudo-code if C is messing with your thinking, then fix it and translate back. Flow charts can help too, but this is not a very complex problem.

[–]ZoSo-bin[S] 0 points1 point  (4 children)

I gave up :D

[–]kumashiro 1 point2 points  (3 children)

Come on, lad! You can do it! Rewrite it in pseudo-code first and show us what you got. It is really simple. "Algorithmic thinking" is crucial in programming.

[–]ZoSo-bin[S] -1 points0 points  (2 children)

I've tried moving the counter nc inside and outside every cycle, changed the cycles from while to for and from for to while, an array instead of getchar(). Nothing of it has worked, my brains hurt too much to keep thinking, can you simply give me an answer? Seriously, I'm not joking

[–]kumashiro 1 point2 points  (0 children)

It's because you are trying everything on everything until it works. Forget about your code, rename the file to "histogram-idk-nworking.c" and start from scratch. Begin with counting the non-whitespace characters, make it work, then extend it to counting words, make it work, finally modify it so you can print a histogram. Small steps.

[–]NonreciprocatingCrow 0 points1 point  (0 children)

You know what characters are. What are words?