0

Go here: http://cdecl.org/

Input:

char (*arr)[5]

Output:

declare arr as pointer to array 5 of char

What is an "array 5"? Does this simply mean an array with 5 elements?

halfer
  • 19,824
  • 17
  • 99
  • 186
Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265
  • Yes, it does. What makes you uncomfortable with that? The fact that arrays can decay into pointers? – jnbrq -Canberk Sönmez Jul 06 '16 at 23:47
  • 1
    @jnbrq-CanberkSönmez An array can implicitly cast to a pointer, which points to the first element, however this 'decay' is not a pointer to an array. What the OP has is an actual pointer to an array – Chris A Jul 06 '16 at 23:49
  • no discomfort, just clarification needed – Gabriel Staples Jul 06 '16 at 23:56
  • @Remy Lebeau, ah, I see how to make the output be a different color now using the > symbol! I had no idea. Where is this magical list of stackoverflow symbology? Also, I find it amusing that we have almost the same reputation points. :) If you just multiply yours by 2 to be as big as mine when multiplied by 1000, they'd be equal. – Gabriel Staples Jul 06 '16 at 23:59
  • 1
    @GabrielStaples Check here: http://stackoverflow.com/editing-help – Chris A Jul 07 '16 at 00:02
  • Thanks for the link. – Gabriel Staples Jul 07 '16 at 00:07
  • @GabrielStaples: indenting text by 4 chars is used for code formatting. `>` is for quoting text. – Remy Lebeau Jul 07 '16 at 00:24

1 Answers1

1

It is a pointer to an array of 5 elements.

//Standard array
char array[5];

//pointer to array
char (*arr)[5];

//Assign pointer of array to arr
arr = &array;

//Dereference arr and use it.
(*arr)[1] = 4;

Pointers and references to arrays are useful for passing arrays to functions, as well as returning them. Do not return local non-static arrays though as their life time ends on return.

To reference an array you can use this declaration: char (&arr)[5] = array;

Chris A
  • 1,475
  • 3
  • 18
  • 22