I have this character count program that takes the Gettysburg Address from an input file and is supposed to count how many of each letter there are. Problem is when I run it, it gives me an infinite loop of the characters and all there counts say some big negative number like -85620 or something. Now I know this means I have an infinite loop or something else amateur, but I am new to programming and do not quite understand my problem. Here is my code:
It does not look like you are processing the file at all. This is the source of your infinite loop.
What you need to make sure of is that the array counters is initialized to 0 (use your countfunction()) and then step by step process each line of the address. (read in each line and then process it character by character)
try this:
string line;
while (!inFile.eof())
{
getline(inFile, line);
for(int i = 0; i < line.length(); i++)
{
if(tolower(line[i]) <= 122 && tolower(line[i]) >= 97)
{