Vectors, Error testing help

I have a vector that has the user enter student marks, but if you dont enter a float it will screw up, im trying to make it so that if you enter anything other than a float it will give a message instead of end the program. Here is my program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <vector>

using namespace std;

 int main()
 {
     vector<float> student_marks(10);

     for (vector<float>::size_type i = 0; i < 10; i++)
     {
         cout << "Enter marks for student #" << i+1 << ": " << flush;
         cin >> student_marks[i];
     }else if(student_marks != float){
      cout << "Error invalid" << endl;
     }
 }
This has nothing to do with vector. See http://www.cplusplus.com/articles/S3wTURfi/
Topic archived. No new replies allowed.