I'm willing to lose some reputation for this question because I'm not understanding why my C++ program is not working. I'm learning about C++ pointers, and I kind of get the concept, but I'm not able to apply the syntax. I assume the lines of commented code are failing because I'm trying to access an invalid location in the memory, but where am I going wrong? The uncommented lines work
Program
#include <iostream>
using namespace std;
int main()
{
/* int * pointer; // These commented lines don't work
*pointer = 23;
cout << "Pointer: " << pointer
<< "\n*Pointer: " << *pointer
<< "\n&Pointer: " << &pointer; */
int *noPointer;
int no_one = 1;
noPointer = &no_one; //taking this line out gives a warning, but doesn't hurt program
*noPointer = 10;
cout << noPointer << " " << *noPointer;
return 0;
}
dereferenceit OR you could guess a valid memory location the lies in between your program.