I'm currently going through a C++ primer and one of the exercises was to create storage of various types using "new," to print the addresses and then delete them. Here is my code:
It prints the address fine except for the pointer to char. This is what I get:Code:#include <iostream>
using namespace std;
int main()
{
int* i = new int;
long* l = new long;
char* c = new char;
float* f = new float[100];
cout << "Address of i: " << i << endl;
cout << "Address of l: " << l << endl;
cout << "Address of c: " << c << endl;
cout << "Address of f: " << f << endl;
delete i;
delete l;
delete c;
delete f;
getchar();
return 0;
}
How come the char* is printing as garbage?Code:Address of i: 007D4B50
Address of l: 007D4B90
Address of c: ═²²²²½½½½½½½½■ε■
Address of f: 007D4C10