Char_Count' : local function definitions are illegal.
#include <iostream>
using namespace std;
int Char_Count (char*);
int main()
{
char ch;
char line[81];
char* ch_ptr;
cout << "Enter a line of words:" << endl << endl;
cin.getline(line, 81);
cout << "\nEnter a character:" << endl << endl;
ch = cin.get();
// Skip any blanks at the beginning of the line
for (ch_ptr = line; *ch_ptr == ' '; ++ch_ptr);
return 0;
int Char_Count(char* ch_ptr)
{
int letter_count = 0
// Process rest of line
do
{
if (*ch_ptr == ch)
{
++ch_ptr;
++letter_count; // Count the letter
}
else
++ch_ptr;
// Skip the word
// for (; (*ch_ptr != '\0'); ++ch_ptr); ;
// Skip blanks after the word
// for (; *ch_ptr == ' '; ++ch_ptr);
}
while (*ch_ptr != '\0');
;
cout << "\nThe line you entered has " << letter_count;
cout << " occurrences of the character " << ch << "." <<endl;
return letter_count;
}

New Topic/Question
Reply




MultiQuote





|