Hello all,
first i would like to say that iŽam Dutch, so if my english Grammar sucks or you dont understand what i mean. tell me .
I have a little question about C++ and pointers. I started with the beginners tutorials on Cprogramming.com. and now it explains pointers.
could somebody explain me what this part of the tutorial (see Quote) means, I think it says, it is very dangerous for a program to use a pointer without declare a value to it(see code below). this program return the value 1474660693 to me, I think this is a random value from something that is stored in the memory location. is this what the writer of the tutorial(see Quote below) ment?
Code:
.
#include <iostream>
using namespace std;
int main()
{
int *p;
cout<<*p;
cin.get();
}
Notice that in the above example, pointer is initialized to point to a specific memory address before it is used. If this was not the case, it could be pointing to anything. This can lead to extremely unpleasant consequences to the program. For instance, the operating system will probably prevent you from accessing memory that it knows your program doesn't own: this will cause your program to crash. If it let you use the memory, you could mess with the memory of any running program--for instance, if you had a document opened in Word, you could change the text! Fortunately, Windows and other modern operating systems will stop you from accessing that memory and cause your program to crash. To avoid crashing your program, you should always initialize pointers before you use them.
Thank for you help:
Jelte,