| Howlz (8) | ||||
|
Firstly I am a first timer noob at programming so a sample program or the below program with your edits and tweaks would be awesomely helpful. Thank you. I want to make a program that prompts an input(a string) and then returns or prints out the number of times a letter and a space occurs in the string FOR EVERY LETTER OF THE ALPHABET. Here is my code which is obviously not working:
(And this is the error it gives when debugging just in case you needed it)
Please do help me, i really appreciate! | ||||
|
|
||||
| Zephilinox (548) | |||
I hope you realize that what you are writing isn't C++, but C.
you're declaring Alphabet twice get rid of the first one. | |||
|
|
|||
| Chervil (812) | |
|
Zephilinox has identified the cause of the error. (and that the code isn't C++). However, an array of integers is probably needed, in order to maintain separate counts for each letter (and space!). The for loop at line 24 probably needs to be modified in order to increment the appropriate separate count. In fact not just modified, but considerably enhanced/changed.And then, you need to do something with the results (print out?). | |
|
Last edited on
|
|
| Howlz (8) | |
| what's the difference between c and c++ and thanks for the advice Zephilinox but how do i modify the loop to get what i'm asking for? | |
|
|
|
| Zephilinox (548) | ||||||
these are c headers, the C++ version of these are
I believe its the same code, but wrapped in the std namespace. printf(sentence);also C, as are many of the other functions you used. Basically, your code is C if it compiles in C compiler, and your code is C++ if it doesn't (but most of C can be compiled in a C++ compiler) because I don't know C, I can't really fix your code without looking through C documentation, but this is how I would do it in C++
| ||||||
|
Last edited on
|
||||||
| Howlz (8) | |
| Thanks but it doesn't still give me the occurence of the rest of the alphabets and the spaces | |
|
|
|