The following code contains three serious memory bugs, usually ending
in a segmentation fault. Find the bugs, solve them and explain them.
// this program is buggy
#include<iostream>
int main(int argc, char** argv) {
using namespace std;
double* d = new double;
for(unsigned int i = 0; i < 3; i++) {
d[i] = 1.5 + i;
}
for(unsigned int i = 2; i >= 0; i--) {
cout << d[i] << endl;
}
}