could you help me about this problem?

K

Keith Thompson

pete said:
Keith said:
softwindow said:
On 2ÔÂ28ÈÕ, ÏÂÎç1ʱ19·Ö, (e-mail address removed) (Peter "Shaggy"
Haywood) wrote: [134 lines deleted]

thank a lot!

thanks for your excellent explaining!

There was no need to repeat the whole thing.

Sometimes I do that as a cheap and easy way of saving
the explanation in my email "Sent box".

Fortunately, I don't recall ever seeing you do that here. Re-posting
an entire article to a newsgroup for your own minor convenience would
be anti-social. (E-mailing it directly to yourself would, of course,
be just fine.)
 
O

Old Wolf

(Peter "Shaggy" Haywood) said:
Here you copy the address of your string literal to your struct
member. Thus, your struct member will point to your string literal. No
other storage has been set aside, and no data copied.

Actually he is setting the struct member to point to the malloc'd
space.
And here you're trying to free memory that was not allocated by
malloc(), calloc() or realloc(). BANG! More undefined behaviour! More
nasal demons! Remember, the nms member of your structure points at a
string literal.

So this is OK (ish).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top