This program keeps giving me the same error while compiling
line 21:
invalid conversion from int to int
initializing argument 1 of void setCounts(int)
line 24:
invalid conversion from int to int
initializing argument 1 of void readAndCount(int, int)
line 27:
invalid conversion from int to int
initializing argument 2 of void displayCounts(int, int)
line39:
declaration of char_count as array references
expected ) before , token
expected unqualified-id before int
//This program reads text from the user and returns
//a count for each letter used in addition to the
//number of words used in the text.
#include <iostream>
using namespace std;
void setCounts(int char_count);
void readAndCount(int char_count, int word_count);
void displayCounts(int word_count, int char_count);
int main()
{
//declarations
int word_count = 0;
int char_count[26];
// intialize character counts to 0
setCounts( char_count);
// read and count characters and words
readAndCount ( char_count, word_count);
if anyone could help me out, it'd be greatly appreciated. I just started toying with C++ a couple months ago and i think my big problem are arrays and functions.
In the definition of readAndCount() you don't need to pass the array by reference. When you pass an array the changes made in the function will apply to it. Passing word_count by reference is needed though.