![]() |
Help
i want to make a program in c :
but am a bit stuck, so can you anyone jst guide me through it. Basically the program has to read in a whole paragraph, and the the program will have to find the words in the paragraph, then it has to sort the words into alphabetically order and and also count the number of times the word appeared in the paragraph and then print, the words in alphabetically order with the frequency. cheers , if anyone can just guide me through it it would be good. Ps i have developed the sorting algorithm for the program... its an insertion sort. |
Re: Help
Try giving better titles for good responses.
|
Re: Help
How far have you got and where are you stuck? Do you know how to:
- read words from a file? - store the words in a suitable data structure, updating the count if the word is already present? - sort the data into alphabetical order? If you're stuck on a specific part of the code, can you post a MINIMAL sample that shows the problem, explaining what exactly it isn't doing that you want it to (or is doing that you don't want it to)? |
Re: Help
@topic Creator:
Admin is correct rather than making jst Help making effective title of furm, like Help In C programming or else. |
Re: Help
Here is my code for scanning my function,
i need help on storing the word in an array; the program must find 1000 unique words. i have already implemented a sorting algorithm and am working on the frequency count rite now Code:
#include<stdio.h> |
Re: Help
@above
do u want to jst store 1000 of charactor in a array, or what i found your code complex |
Re: Help
It would make sense to store the word and its count in an STL map ( http://en.wikipedia.org/wiki/Map_(C%2B%2B_container) ) using the word as the key and the count as the data.
Then you don't need a counting algorithm as such; when you want to add a word to the list, first check it exists, if it does you increase the count; if not just add it with a count of 1. Also you don't need a sorting algorithm as map handles this for you. However if you're not allowed to use the STL then perhaps just store a struct of the string and its count in a static array (malloc), resizing it as necessary (realloc). Use insertion sort, i.e. just place a new word into its correct place and shift the remaining items up; this is likely to be quick enough on modern systems. |
Re: Help
hi guys
i made a scan function, but the compiler at uni doesn't like it, also gets only allows me to input multiple lines of code, which i need for my program, help anyone please!!! Code:
printf("Enter the text:\n"); |
Re: Help
Please be more specific. What compiler, and what platform? How exactly doesn't the compiler like it?
What does "gets only allows me to input multiple lines of code" mean? |
Re: Help
I am a new learner. can you help to just find out the frequency of numbers. given input will be in the range of 0 to 9.
Thanking you in advance Amit |
| All times are GMT +5.5. The time now is 05:30. |