Hello,
For a exercise I must make a programm which counts how many times a word is being inputted. It's a exercise from chapter 3 of Accelerated C++
So i thought this will work :
Code:
#include <string>
#include <vector>
#include <iostream>
using namespace std ;
int main()
{
// ask for and read the words to count
cout << "Enter all the words, "
"followed by end-of-file: ";
vector<string> words;
vector<int> words_count ;
int found, place, teller=0 ;
string x ;
while (cin >> x)
{
for (teller ; words.begin(); words.end())
if (x == words[teller] then
{
found = "1"
place = teller
}
if found==1 then
{
words_count [place]+=1 ;
found = 0 ;
}
else
{
words.push_back(x);
words_count.push_back(1)
}
}
for (teller; words.begin();words.end())
{
cout << "Word" << words [teller] << "komt" << words_count[teller] << "voor";
}
return 0;
}
But I get a problem with the for loop.
Who can help me and tell me what's wrong with this line.
Roelof