Creating a string program that counts the number of letters in total.

Hello, I have been trying for a few hours to create a program that counts the number of letters in the ten words that are provided, not including spaces. I am completely lost and any help would be greatly appreciated. I feel like I am missing an extremely simple detail.

Thanks for any help!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  // counts the number of total letters in the 10 words the user entered
// created by ***********
#include <iostream>

using namespace std;

int main()
{
	int wordsAllowed = 10;
	cout << "Please enter " << wordsAllowed << " numbers below. One per line. " << endl;
	
	int wordsEntered = 0;
	string word;
	int i = word.size();
	
	while(wordsEntered < wordsAllowed)
	{
		cout << "---> " ;
		cin >> word;
		int i = i + word.size();
		
		++ wordsEntered;
	}
	
	
	cout << "There are " << i << " letters in total.";
	
}
The i you create on line 20 is not the i you created on line 14.
Topic archived. No new replies allowed.