What question do you have. What you have posted seems reasonable enough. Does it do what you think it should?
Do you the comparison of characters to be case sensitive (F is different from f) or not (F will count as f)? If the latter then you will want to use tolower() to convert each char to lower case if it isn't already before counting the number of fs in the example.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
for (ch_ptr = sentence; *ch_ptr != '\0'; ++ch_ptr);
while (*ch_ptr==letter)
++counter_letter;
Too many problems with that to try to fix it. Try something more like:
int length = strlen(sentence);
for(int i = 0; i < length; ++i)
if the char in sentence with index i equals letter
increment counter_letter
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
Enclose the part you want to repeat in a loop. There are several types of loops available. Basically for repetetions a known number of times, "for" loops are usually used. For repetetions an indefinate number of times, "while" loops are usually used. If you aren't familiar with loops then I recommend you look them up in your favorite reference book/material. As much fun/useful this board may be, it doesn't and never will replace a good reference book/material.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396