1

Below is a part of my code. I am not sure what is wrong with it because when I debug this code, I get a the following error:

Unhandled exception at 0x60e8144c (msvcr90d.dll) in client0.exe: 0xC0000005: Access violation writing location 0x00000000.

This is somewhere in the line itoa.

CODE:

   int num =  LOWORD (lparam);
   char *number = NULL,*detail = NULL;
   (char*)itoa(num,number,10);
Ayse
  • 2,676
  • 10
  • 36
  • 61
  • The runtime error says "I can't write to address 0x00000000". This should make you suspect that a write to a null pointer is taking place. You have such pointers in your program. You write to them. Hence the error message. – Lundin Jun 04 '13 at 06:13
  • What about reading some documentation: http://msdn.microsoft.com/en-us/library/ms235327%28v=vs.110%29.aspx – alk Jun 04 '13 at 06:16

2 Answers2

3

You have to pass a valid initialized pointer to itoa().

Carl Norum
  • 219,201
  • 40
  • 422
  • 469
2

number is pointer and you haven't allocated memory for it. And then trying to write into it.

Update it to use array or allocate memory using malloc

int num =  LOWORD (lparam);
char number[20],*detail = NULL;
(char*)itoa(num,number,10);
Rohan
  • 52,392
  • 12
  • 90
  • 87