Hi guys I am really having a hard time with C programming. Our lectures are very fast and not beneficial to those with non-C backgrounds. We were required to write a code for counting frequency of words from stdin and then listing them in descending order with those with equal length being alphabetized. Please help me because I am really lost with this program. I really need it.
bobcats
0
Newbie Poster
Recommended Answers
Jump to PostRead in user input
http://www.daniweb.com/tutorials/tutorial45806.htmlThen use the space as a delimiter to separate the sentence into words.
http://www.daniweb.com/code/snippet443.html
Once you have your array of words find out their length, possibly using strlen().
To sort those words of the same length alphabetically, use strcmp()
Jump to Post>What I meant with the things not being allowed is that the output wanted was to be straightforward.
The output has no relationship to how you produce the answer. You can solve the problem a dozen wildly different ways and get exactly the same desired output that you posted.…
Jump to PostSir I appreciate your suggestions but I'm really a noob with regards to C such that i don't know how to implement it. Could you give me any sample/hint. Sorry for being very slow with this part. Hope you could understand.
Follow Dave's suggestion at your GID …
Jump to PostBelow is your code after the while loop in main() has completed. I have added comments and suggestions based on your previous posts.
/* find maximum frequency within WordCounter */ Maxcount = 0; for (i = 0; i < UniqWords; i++) { if (WordCounter[i] > Maxcount) { …
Jump to Postwhy don't you use qsort from the library?
All 38 Replies
iamthwee
bobcats
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
bobcats
0
Newbie Poster
John A
1,896
Vampirical Lurker
Team Colleague
Narue
5,707
Bad Cop
Team Colleague
Salem
5,138
Posting Sage
iamthwee
bobcats
0
Newbie Poster
iamthwee
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
iamthwee
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
iamthwee
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
iamthwee
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
Narue
5,707
Bad Cop
Team Colleague
~s.o.s~
commented:
*shoots himself in the head* I overlooked that possibility, thanks - ~s.o.s~
+14
iamthwee
Narue
5,707
Bad Cop
Team Colleague
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
Narue
5,707
Bad Cop
Team Colleague
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
Narue
5,707
Bad Cop
Team Colleague
Lerner
582
Nearly a Posting Maven
iamthwee
bobcats
0
Newbie Poster
Lerner
582
Nearly a Posting Maven
bobcats
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.