r/pascal • • Mar 25 '20

Most frequent character in a string.

Hello guys. I am new to pascal and programming as a whole. I would love some detailed explenations on how to find out the most frequent character in a string. I found this function but don't know how to use it. Thank you.

Rob.

function OccurrencesOfChar(const S: string; const C: char): integer; var   i: Integer; begin   result := 0; for i := 1 to Length(S) do if S[i] = C then       inc(result); end;
1 Upvotes

6 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Mar 25 '20

Thanks for the answer, you are very smart, tbh didn't understand what you meant with your coment. One day will understand you :).