I've looked through various questions both here and other places, but I still cannot explain the access violation error I'm getting. "Access violation writing location 0x00000000" corresponds to a NULL pointer, correct? I've declared an int pointer, and I later try to set a value at that location. Shouldn't the memory space be allocated when I declare the pointer? Forgive me if this is noobish, but I'm much more of a Java/AS3 guy.
Here is a portion of my code...
int* input;
char* userInput[1];
int* output;
int _tmain(int argc, _TCHAR* argv[])
{
while(1)
{
srand(time(0));
*input = (int)(rand() % 10);
It breaks at the last line.
Memory is allocated for the pointer, but the pointer itself still doesn't point anywhere. Use new
to allocate memory for the pointer to point to, and free it with delete
later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With