Need help with Ascii and counting characters

SoundTheSurrender

Diamond Member
Mar 13, 2005
3,126
0
0
I need to write a program that will take input from the user and count them. I'm trying to compile this program but I can't get it to compile.

#include <iostream>
#include <iomanip>



using namespace std;

int isAlpha(char ch);




int main()

{

char ch;

int alphaCounter = 0;

cout <<"Please enter a something";

cin.get(ch);

while (ch != '.')

{
while (ch!= '\n')

{

isAlpha(ch);





}



return 0;
}











while isAlpha(char ch)

{

if (ch >= 'A' and ch <= 'Z')


{

alphaCounter += ch;

}

else (ch>= 'a' and ch <= 'z')

{

cout <<"2222";

}



return 1;

}

 

Matthias99

Diamond Member
Oct 7, 2003
8,808
0
0
If it's not compiling, please list the compilation errors.

Also, use the 'attach code' box so it's formatted properly. Trying to read code with no indentation is painful at best.

Edit:

One obvious problem is that (if that is your full source) you didn't actually define the body of function 'isAlpha()'. Your braces also aren't balanced.
 

Aikouka

Lifer
Nov 27, 2001
30,383
912
126
Your outer while loop in the main function is missing an ending curly bracket.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,591
5
0
Your inner loop never gets another character.

Your cin.get needs to be within a loop somewhere to get the next entered character.