![]() |
|
#1
|
|||
|
|||
Recurrence of letters in a stringI've been working on this code for a while now, and for() loops always get me lost. I understand their concept, but geez they kill me.
The purpose of the program is to input a string that ends with a period, and to then calculate the number of words in the string and give an output of the reoccurance of the letters. If I input: I say Hi. It should output: 3 words 1 a 1 h 2 i 1 s 1 y the code is going in the right direction, but it messes up for some reason converting the string to lowercase, and the output tries to output all 26 letters, but seemingly skips a few...so i'm sorta confused what thats doing too. Help please? CPP / C++ / C Code:
|
|||
|
#2
|
|||
|
|||
Re: reoccurance of letters in a string....ughFor starters, I don't see anywhere where you actually use the letterCount array. First, you need to initialize it so that all of the values start at zero. That is why you are getting weird values. Then, you'll have to increment the positions when you come across them.
|
|
#3
|
|||
|
|||
Re: reoccurance of letters in a string....ughMoreover, i didn't see that you actually counting each alphabet.
|
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multiple questions for C++ project | devster420 | C++ Forum | 1 | 20-Apr-2007 22:26 |
| Message Class | TransformedBG | C++ Forum | 5 | 29-Nov-2006 22:28 |
| Need help with strings | sasukekun | C++ Forum | 4 | 24-Apr-2006 11:51 |
| variables return to previous value after i try to set them | nasaiya | MS Visual C++ / MFC Forum | 2 | 14-Jun-2005 01:43 |
| Help wit my source code compiler errors | Krandygrl00 | C++ Forum | 1 | 06-Jun-2005 09:14 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The