im having a problem...i have a program to count number of senteces one inputs..the words and asking for a letter. The end of "\\close count" works fine...but for some reason the sentence and word programs doesnt work. could anyone please check this out. I think Iam missing something. I have 3 three separate but I need them to link together into one for it to work. Thanks for the help
#include <string.h>
#include <iostream.h>
using namespace std;
void main()
{
int count(char *, char), words, senten;
char userString[51], letter;
cout << "Enter a sentence : ";
cin.getline(userString, 51);
cout << "Enter a letter \n";
cin >> letter;
cout << letter << " appears ";
cout << count(userString, letter) << " times.\n";
} //close main
int count(char *str, char ch)
{
int times = 0;
while(*str != '\0')
{
if (*str == ch)
times++;
str++;
}//close while
return times;
}// close count
int words
{
int words = 1;
while(*str != '\0')
{
string userString;
getline(cin, userString);
for(i = 0; i < userString.length(); i++)
{
if(userString.at(i) == ' ')
words++;
}
cout << "Number of words in text: " << words << endl;
}//close words
}
int senten
{
int senten = 0;
while (*str == ch)
{
switch (ch)
{
case '.' || case '?' :
sentence_count++;
break;
cout << "There is/are " << senten << " sentence/s" << endl;
return 0;
<< moderator edit: added [code][/code] tags >>