Are you sure you want to do this? It seems that you are wanting to do something very advanced and dangerous and are having a very basic doubt. This combination does not usually work out.
Is the application allowed to write to this area of memory? Luckily the operating system controls this and even though it does not let the application write anywhere in memory. You can not write to other applications or even parts of your own application.
Were the variables used correctly set ? I will consider that yes, after all you did not put every part of the program and you should consider that there is a problem only in this line.
Then just read an integer and use it as a pointer as you were already trying to do. Probably the problem is that I was reading a string .
int endereco;
scanf("%d", &endereco);
int isSuccessful = WriteProcessMemory(hproc, (LPVOID)endereco, &NewValue, (DWORD)sizeof(NewValue), NULL);