Hello, I have a program I am writing to count the number of integers (as well as the individual digits) in a file. I feel I'm close but I'm not quite there so any insight would be helpful.
I'll only post the segments of code relevant to where I need help.
My main function:
do
{
text.get(ch);
if(isdigit(ch))
{
sum = Integers(ch, count3, text);
numofint++;
}
} while(!text.eof());
Integers function:
int Integers(char &ch, int &counter, ifstream& text)
{
int total = 0;
int sum = 0;
bool success = true;
while((isdigit(text.peek()) == success))
{
counter++;
total = (total*10) + (static_cast<int>(ch)-48);
sum += total;
}
return sum;
}