Re: General method for dynamically allocating memory for a string
- From: Ben Pfaff <blp@xxxxxxxxxxxxxxx>
- Date: Wed, 30 Aug 2006 16:51:34 -0700
"smnoff" <343rhinosourueus@xxxxxxxxxxx> writes:
I have searched the internet for malloc and dynamic malloc; however, I still
don't know or readily see what is general way to allocate memory to char *
variable that I want to assign the substring that I found inside of a
string.
If you want to allocate memory for a string, pass the number of
non-null characters in it, plus one, to malloc, then copy the
string into it, being sure to null-terminate the result.
If you can be more specific about what you're trying to do,
perhaps we can help with some details.
--
"I hope, some day, to learn to read.
It seems to be even harder than writing."
--Richard Heathfield
.
- Prev by Date: Re: strncpy not that easy to use
- Next by Date: Please help me with algorithms !!!
- Previous by thread: Dynamic buffer library
- Next by thread: Re: General method for dynamically allocating memory for a string
- Index(es):
Relevant Pages
|