Hello all! Beginner programmer here. I'm trying to write a program to output the most frequent character in the string but the output isn't working properly... Please help point out my problem! I'm lost!
#include <iostream>
usingnamespace std;
char charArray[50];
int i, arraySize;
char getMostFrequentChar(char charArray[], int arraySize) {
char max = charArray[0];
arraySize = strlen(charArray);
for (i = 0; i < arraySize; i++) {
if (charArray[i] > max) {
max = charArray[i];
}
}
cout << "The most frequent character is: " << max << "\n";
return 0;
}
int main() {
cout << "Enter a word: ";
cin >> charArray;
getMostFrequentChar(charArray, arraySize);
system("pause");
return 0;
}