// ConsoleApplication25.cpp : main project file.
#include "stdafx.h"
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
#include <vector>
#include <algorithm>
using namespace System;
using namespace std;
int main()
{
vector<string> words;
string x;
cout << "Enter words followed by end of file: " << endl;
while (cin >> x){
words.push_back(x);
}
cout << endl;
int count=0;
string Uword;
cout << "Enter the word you want me to count" << endl;
cin >> Uword;
for(int i = 0; i < (int)words.size(); ++i){
if (Uword == words[i]){
++count;
}
}
cout << "You word appeared " << count << " times" << endl;
system("pause");
return 0;
}
Can some one tell me what I did wrong ? :/ Clearly I don't understand a key concept. The program keeps skipping my second cin
. and doesn't even look at the for loop and I don't have any idea why.