Click here to Skip to main content
14,391,870 members

C / C++ / MFC

 
QuestionHow to make the heap address(by new) have the same every time the program runs? Pin
Member 1308136910-Nov-19 16:36
MemberMember 1308136910-Nov-19 16:36 
AnswerRe: How to make the heap address(by new) have the same every time the program runs? Pin
k505410-Nov-19 17:19
Memberk505410-Nov-19 17:19 
GeneralRe: How to make the heap address(by new) have the same every time the program runs? Pin
Member 1308136920-Nov-19 16:48
MemberMember 1308136920-Nov-19 16:48 
AnswerRe: How to make the heap address(by new) have the same every time the program runs? Pin
CPallini11-Nov-19 23:10
mveCPallini11-Nov-19 23:10 
GeneralRe: How to make the heap address(by new) have the same every time the program runs? Pin
Member 1308136920-Nov-19 16:49
MemberMember 1308136920-Nov-19 16:49 
QuestionRe: How to make the heap address(by new) have the same every time the program runs? Pin
David Crow12-Nov-19 6:46
MemberDavid Crow12-Nov-19 6:46 
AnswerRe: How to make the heap address(by new) have the same every time the program runs? Pin
Member 1308136920-Nov-19 16:56
MemberMember 1308136920-Nov-19 16:56 
AnswerRe: How to make the heap address(by new) have the same every time the program runs? Pin
leon de boer13-Nov-19 3:34
Memberleon de boer13-Nov-19 3:34 
The question is stupid, there is no way a dynamic heap manager can guarantee it wont give the memory space away to some other call for memory allocation. To do what you asked it would have to keep the memory "available" anyhow, so for the love of all things coding just declare the thing static in that case (unless you actually want a global).

My C++ is rusty with string objects but it should be something like
static char* str = char[128];

In C it is simpler
static char str[128];

Problem solved it now has the same address everytime locally, and effectively does the same thing that any crazy heap manager doing what you asked would have to do.

I am assuming you are going to change the string at times, so you want a variable not a constant.
In vino veritas


modified 13-Nov-19 8:47am.

GeneralRe: How to make the heap address(by new) have the same every time the program runs? Pin
Richard MacCutchan13-Nov-19 6:01
mveRichard MacCutchan13-Nov-19 6:01 
QuestionCTreeCtrl item images without CImageList ? Pin
Maximilien30-Oct-19 9:32
MemberMaximilien30-Oct-19 9:32 
AnswerRe: CTreeCtrl item images without CImageList ? Pin
Richard MacCutchan30-Oct-19 10:42
mveRichard MacCutchan30-Oct-19 10:42 
GeneralRe: CTreeCtrl item images without CImageList ? Pin
Maximilien30-Oct-19 13:04
MemberMaximilien30-Oct-19 13:04 
QuestionFTPS Connection Pin
Paul201324-Oct-19 11:28
MemberPaul201324-Oct-19 11:28 
QuestionRe: FTPS Connection Pin
David Crow29-Oct-19 10:10
MemberDavid Crow29-Oct-19 10:10 
AnswerRe: FTPS Connection Pin
Paul201330-Oct-19 9:25
MemberPaul201330-Oct-19 9:25 
QuestionRe: FTPS Connection Pin
David Crow30-Oct-19 11:17
MemberDavid Crow30-Oct-19 11:17 
AnswerRe: FTPS Connection Pin
Paul201330-Oct-19 12:30
MemberPaul201330-Oct-19 12:30 
Question.bmp and .ico MFC vc++ Pin
Member 1457555624-Oct-19 3:21
MemberMember 1457555624-Oct-19 3:21 
QuestionRe: .bmp and .ico MFC vc++ Pin
David Crow24-Oct-19 3:41
MemberDavid Crow24-Oct-19 3:41 
AnswerRe: .bmp and .ico MFC vc++ Pin
Member 1457555624-Oct-19 3:59
MemberMember 1457555624-Oct-19 3:59 
QuestionRe: .bmp and .ico MFC vc++ Pin
David Crow24-Oct-19 4:17
MemberDavid Crow24-Oct-19 4:17 
AnswerRe: .bmp and .ico MFC vc++ Pin
Member 1457555625-Oct-19 4:23
MemberMember 1457555625-Oct-19 4:23 
GeneralRe: .bmp and .ico MFC vc++ Pin
leon de boer24-Oct-19 16:10
Memberleon de boer24-Oct-19 16:10 
GeneralRe: .bmp and .ico MFC vc++ Pin
Richard MacCutchan24-Oct-19 22:42
mveRichard MacCutchan24-Oct-19 22:42 
GeneralRe: .bmp and .ico MFC vc++ Pin
Victor Nijegorodov25-Oct-19 0:19
MemberVictor Nijegorodov25-Oct-19 0:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.