Jump to content
  • Advertisement

Archived

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

Sfpiano

Differences with dynamic and static memory

This topic is 5406 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If I use this: short array[6*256]; Everything works out fine. But if I do this: short* array; array = new short[6*256]; I get problems. What''s the difference? //----------------------------------------------------------------------------------------------------------------- The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you''re the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."

Share this post


Link to post
Share on other sites
Advertisement
Probably just that you''re using a pointer instead of a regular variable... if you want the value at the memory location contained in the pointer (the space you allocated), you need to use an * before the pointer name... and stuff

Share this post


Link to post
Share on other sites
That''s what I thought might be it, but the array is inside of a struct. If list is an array of the structs, I know you can''t do *list[0].array[0], but how would you do it? And my wierd error causes my computer to reboot whenever I try to access the data in the index buffer which was was passed through array[].

//-----------------------------------------------------------------------------------------------------------------
The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you''re the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."

Share this post


Link to post
Share on other sites
I think you need to give more information, such as exactly what your problem is and the code that goes along with it. Otherwise, no one will be able to help you out.

Share this post


Link to post
Share on other sites
quote:
Original post by Sfpiano
If list is an array of the structs, I know you can''t do *list[0].array[0]



struct x { char *y; };

struct x myx[100];
myx[0].y = new char[100];
myx[0].y[0] = 0; // set the first char of the first struct to 0

Share this post


Link to post
Share on other sites
in my struct:
short* s_pIndices;

In my program:

myStruct* data;
data = (QT_NODE*)malloc(sizeof(QT_NODE)*iNumNodes);

data[ i ].s_pIndices = new short[6*min*min];
nArrayIndex=0;
for(i=0; i<5; i++){
for(j=0; j<5; j++){
pNodeList[iNodeID].s_pIndices[nArrayIndex]=((i+1) * 256)+j;
nArrayIndex++;
}
}


//-----------------------------------------------------------------------------------------------------------------
The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."

[edited by - Sfpiano on September 4, 2003 4:53:03 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!