user66820: int colors[][3] = {
  { 255, 0, 0 }, 
  { 0, 255, 0 }, 
  { 0, 0, 255 },  
  { 253, 7, 210 }
};
int (*EXCLUSIVE_COLOR)[3];

I have a two-dimensional array to store some color values.
I have a 2nd array, which I am using to assign an "EXCLUSIVE_COLOR" from the first colors array.
What is the best method to assign a null or empty value to the "EXCLUSIVE_COLOR" array to be used upon initialization and when the "EXCLUSIVE_COLOR" is unset?
Initially I tried just assigning a default value to the array upon initialization:
int (*EXCLUSIVE_COLOR)[3] = {0,0,0};
//Produces an error: scalar object ‘EXCLUSIVE_COLOR’ requires one element in initializer

int (*EXCLUSIVE_COLOR)[3] = {0};
//assigns non-zero values to all three elements

I know that I can add a "dummy" record to the colors array to reference, when there isn't an "EXCLUSIVE_COLOR" set.
int colors[][3] = {
  { 255, 0, 0 }, 
  { 0, 255, 0 }, 
  { 0, 0, 255 },  
  { 253, 7, 210 }, 

  { 0, 0, 0, }   //dummy record
};
int (*EXCLUSIVE_COLOR)[3] = &colors[4];

However I wanted to know if there was a cleaner way to be able to assign an empty value to reference when a color is not set, and when the array is initialized.

user4143: If you're using a pointer then there's no limit to what that pointer can point to.
The way I see it you have two sensible choices:

Point to a default value

This doesn't have to be in your array. It can be anything that is an int[3], since that is what your array consists of.
int[3] nothing = {0, 0, 0};

EXCLUSIVE_COLOR = nothing;

This means that it's actually pointing to something valid, in this case it's actually (I assume) the colour black.  That can make it easy to deal with, since EXCLUSIVE_COLOR[0] will be a valid value.

Point to nothing

You can point your pointer to NULL and it will be pointing to "nothing". This means that EXCLUSIVE_COLOR[0] is no longer valid, which can make handling it somewhat harder. However it does allow you to distinguish between "nothing" and "black", unlike option 1.
For example:
EXCLUSIVE_COLOR = colors[2]; // {0, 0, 255}
...
EXCLUSIVE_COLOR = NULL; // Not pointing anywhere

To test if it's pointing somewhere you can simply use if:
if (EXCLUSIVE_COLOR) { 
   // you have a valid entry
}


66820: <pre><code>int colors[][3] = {
  { 255, 0, 0 }, 
  { 0, 255, 0 }, 
  { 0, 0, 255 },  
  { 253, 7, 210 }
};
int (*EXCLUSIVE_COLOR)[3];
</code></pre>

<p>I have a two-dimensional array to store some color values.<br>
I have a 2nd array, which I am using to assign an <strong>"EXCLUSIVE_COLOR"</strong> from the first colors array.</p>

<p>What is the best method to assign a null or empty value to the <strong>"EXCLUSIVE_COLOR"</strong> array to be used upon initialization and when the <strong>"EXCLUSIVE_COLOR"</strong> is unset?</p>

<p>Initially I tried just assigning a default value to the array upon initialization:</p>

<pre><code>int (*EXCLUSIVE_COLOR)[3] = {0,0,0};
//Produces an error: scalar object ‘EXCLUSIVE_COLOR’ requires one element in initializer

int (*EXCLUSIVE_COLOR)[3] = {0};
//assigns non-zero values to all three elements
</code></pre>

<p>I know that I can add a "dummy" record to the colors array to reference, when there isn't an <strong>"EXCLUSIVE_COLOR"</strong> set.</p>

<pre><code>int colors[][3] = {
  { 255, 0, 0 }, 
  { 0, 255, 0 }, 
  { 0, 0, 255 },  
  { 253, 7, 210 }, 

  { 0, 0, 0, }   //dummy record
};
int (*EXCLUSIVE_COLOR)[3] = &amp;colors[4];
</code></pre>

<p>However I wanted to know if there was a cleaner way to be able to assign an empty value to reference when a color is not set, and when the array is initialized.</p>
 4143: <p>If you're using a pointer then there's no limit to what that pointer can point to.</p>

<p>The way I see it you have two sensible choices:</p>

<ol>
<li>Point to a default value</li>
</ol>

<p>This doesn't have to be in your array. It can be anything that is an <code>int[3]</code>, since that is what your array consists of.</p>

<pre><code>int[3] nothing = {0, 0, 0};

EXCLUSIVE_COLOR = nothing;
</code></pre>

<p>This means that it's actually pointing to something valid, in this case it's actually (I assume) the colour black.  That can make it easy to deal with, since <code>EXCLUSIVE_COLOR[0]</code> will be a valid value.</p>

<ol start="2">
<li>Point to nothing</li>
</ol>

<p>You can point your pointer to <code>NULL</code> and it will be pointing to "nothing". This means that <code>EXCLUSIVE_COLOR[0]</code> is no longer valid, which can make handling it somewhat harder. However it does allow you to distinguish between "nothing" and "black", unlike option 1.</p>

<p>For example:</p>

<pre><code>EXCLUSIVE_COLOR = colors[2]; // {0, 0, 255}
...
EXCLUSIVE_COLOR = NULL; // Not pointing anywhere
</code></pre>

<p>To test if it's pointing somewhere you can simply use <code>if</code>:</p>

<pre><code>if (EXCLUSIVE_COLOR) { 
   // you have a valid entry
}
</code></pre>
