malloc causing memory leaks?

Started by
10 comments, last by ProgrammerDave 20 years, 8 months ago
quote:Original post by Agent1
That would just return the size of the type used to hold the MAX_STR constant, not the actual value in it.



-Agent1


That''s what I meant, Agent1.



Beginners and experts will find answers here.
Advertisement
quote:Original post by Mathematix
quote:Original post by Agent1
That would just return the size of the type used to hold the MAX_STR constant, not the actual value in it.


That's what I meant, Agent1.


I don't understand. It's wrong to use sizeof(MAX_STR) if you want to allocate characters to hold that many characters. What you should do is use:
malloc(sizeof(char) * MAX_STR); 




-Agent1

[edited by - Agent1 on August 15, 2003 1:47:25 PM]

This topic is closed to new replies.

Advertisement