2012-04-29 16 views

答えて

8

http://cdecl.org/

  1. char (*p)[4];は - チャーのアレイ4へのポインタとしてPを宣言する。
  2. char *p[4]; - pをcharへのポインタの配列4として宣言します。
+0

この「pをcharの配列4へのポインタとして使用する」 –

+2

しかし、あなたは必要ですが! –

+0

は* p [0] = "Hello"です。または* p [0] =(char *)malloc(10);最初の宣言のために有効 –

4

char (*p)[4];p 4.

      char [4] 
    points to    | 
    char [4]    v 

    +------+    +------+------+------+------+ 
    | p |------------>|  |  |  |  | 
    +------+    +------+------+------+------+ 
         char char char char 

    p will point to a char [4] array. Array is not created. 
    p is intended to be assigned at address of a char [4] 

char *p[4];長のchar配列へのポインタである:pは長さ4の配列であり、配列の各位置はchar

へのポインタであります
   +------+------+------+------+ 
    p   |  |  |  |  | 
an array  +------+------+------+------+ 
itself   |  |  |  | 
       v  v  v  v 
       char* char* char* char* 

    p is an array and will be allocated in stack (if automatic) 
+0

ありがとうございます!とった!! –

+0

ポインタの場合、画像は常に役に立ちます:) – phoxis

+2

'char(* p)[4]'の場合、宣言は配列を作成せず、ポインタを作成するだけです。 – kittemon

関連する問題