No errors but code will not run

I get no errors, the code runs and then this weird screen pops up. can anyone help me with this problem?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 #include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
	double *deposit = 0; //Line 1
	double *intRate = 0; //Line 2
	double interest = 0; //Line 3
	deposit = new double; //Line 4
	*deposit = 25000; //Line 5

	interest = (*deposit) * (*intRate); //Line 6
	cout << "This is the outcome of Class Lab 14: " << interest << endl; //Line 7
	
	system("pause");
	return 0;
}
interest = (*deposit) * (*intRate); //Line 6 double *intRate = 0; //Line 2
intRate is a null pointer, so when you dereference it your program will most likely crash.
I don't see the need of using pointers and dynamic memory. You also forgot to deallocate the memory you used for deposit, resulting in a memory leak.
Topic archived. No new replies allowed.