This should give you some ideas how to solve the problem. This just counts the number of inteters until '\n' is detected. You should be able to construct a function that does something similar for what you want.
using namespace std;
int count = 0;
cout << "Enter a number\n";
while(cin.peek() != '\n' && cin >> n)
cout << "Count = " << count << "\n";