Eclipse Crashing When Returning Null C++ -


i having issues code. want return null when array size 0. however, when testing in eclipse, crashes. tips?

thanks!

#include <iostream> using namespace std;  double* maximum(double* a, int size) {    if (size == 0)    {       return null;    }    double* m = a;    double* p = a;    (int = 0; < size; i++)    {       if (*p > *m)       {          m = p;       }       p++;    }    return m; }  int main() {    double data[] = {};  double* max = maximum(data, 0);    cout << *max << endl;    return 0; } 

it illegal dereference null pointer, cout << *max << endl;


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -