Jump to content
  • Advertisement

Archived

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

chbfiv

delete problem

This topic is 5562 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

Correct me if im wrong please, the compiler thinks i am at least, and I trust it=) char* tmp = new char[strlen(string)+1]; strcpy(tmp,string); delete [] tmp; tmp = NULL; this should delete tmp, but it has a compile error=/

Share this post


Link to post
Share on other sites
Advertisement
...and the compiler error is...

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Kierkegaard reminds us that belief
has nothing to do with how or why.
Belief is beyond reason.

I believe because it is absurd."

Share this post


Link to post
Share on other sites
Better question, I was using
char* tmp = new char(strlen(string)+1); //I used ()''s instead of []''s
thus the problem, but what is the purpose of making a char(100) like that?
//why
char tmp(100);
//when you use
char tmp[100];

//basicly? It still worked until I called delete on it

Share this post


Link to post
Share on other sites
char tmp(100);

Is calling a function using immediate addressing, that is, passing the literal 100 to function tmp.

char tmp[100];

Is statically declaring an array of 100 locations of type char. The array size would be ''sizeof tmp'' or ''sizeof(char) * 100''.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!