Help creating condition for while loop

I want the while loop inside my function to run as long as characters are being read in to it from main;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 int shiftFinder(char ch) {
	
	int letterCount[26] = {0};
	char letter;
	int index; 
	int mostOften = 0;
	int shift = 0;
	
	while(something happens) {  // here
		letter = toupper(ch);
		index = letter-'A';
		if(index < 26 && index >= 0) {
			letterCount[index]++;
			if (letterCount[index] > mostOften){
				mostOften = index;
			}
		}

		

}
	shift = index - 5; 
	return shift;
	}
Shouldn't the while be where you are calling the function? It only takes one string so should only run once
Yeah, that's something I am confused about.

in my main I have the following

1
2
3
4
while (!fromFile.eof()){
		fromFile >> ch;
		shiftFinder(ch);
	}


It sounds like if I am doing this then I don't need the kind of while loop I'm thinking I need in my function?
Shouldn't need in your shift function but you should put something = shiftFinder(ch) or its s pointless function in your main
Topic archived. No new replies allowed.