Why am i getting this error referring to asserts?

So for college we got a programming project where we have to find the values of a vector and part of it is finding the min and max value
so i created a little start out program and it was going well until i got an error when i would try to run it telling me the vector subscript is out of range
what am i doing wrong?
here's my code :

#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

int main()

vector <double> v;
double x = 0;

while (x != 0)
cin >> x;

double min = 0;
double max = 1000000000000000;
double median = 2;
double average = 0;

for (int i = 0; i < sizeof(v); ++i)
if(v[i] >= max)
max = v[i];

cout << "The max value is: " << max << endl;

for (int i = 0; i < sizeof(v); ++i)
if(v[i] <= min)
min = v[i];

cout << "The min value is " << min << endl;
Last edited on
I think double is limited to (15 digits). I think your using 16.

Last edited on
I tried reducing it and that didnt work, it must be a different problem
sizeof(v) is NOT the size of the vector. It is the size of the class that holds the vector, not the number of elements in the vector. You want to use v.size()
Topic archived. No new replies allowed.