jump to navigation

c-faq review and a chinese translation (1.6) January 25, 2007

Posted by TSAI HONG-BIN in Programming.
trackback

please refer to http://c-faq.com/decl/mimic.html

1.6 I’m trying to declare a pointer and allocate some space for it, but it’s not working. What’s wrong with this code?

char *p;

*p = malloc(10);

The pointer you declared is p, not *p. See question 4.2.

我試著宣告一個指標並且配置一些空間給它,但失敗了。我這樣寫有什麼問題嗎?

char *p;
*p = malloc(10);

你所宣告的指標是 p 不是 *p,請見 section 4.2

Advertisements

Comments»

No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: