Archived

This topic is now archived and is closed to further replies.

Andrew Nguyen

Forceful Memory Allocation

Recommended Posts

Is it possible to do forceful memory allocation? e.g, is
  
#include <iostream>
int *a
int t
void main()
{
  a*t;  
  &t = A001D;
  t=123;
}

  
possible? Just wondering... it could help to organize variable location?

Share this post


Link to post
Share on other sites
What do you mean by forceful memory allocation? Your code example didn''t help me much since it doesn''t make sense . Do you mean writing to a specific place in memory? If that''s what you mean then yes it is technically possible, but it''s more likely that your application will segfault. You''d basically do it like this:
  
int *Fish = 0x12341234;
*Fish = 999;

That would try to set the memory (of sizeof(int) bytes) at 0x12341234 equal to 999. Of course, that''s going to cause your application to crash . You may also want to look at ''placement new''.

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites