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
Post a Comment