user34518: In my program I have the following lines of code:
if (invest == {0, 1, 0, 0})
   {
      //code 
   }

However, upon attempting to compile the code, I receive the following error:
exit status 1
expected ';' before '}' token

"Invest" is a bool array originally defined with`
bool invest[] = {0, 0, 0, 0};

How can I prevent this error from ocurring?

user19409: Unfortunately you cannot do that.
In addition to Michel Keijzers, another possible way is to use binary manipulation of an integer.
Your declaration of the variable would look like this:
unsigned int invest = 0x00;    // B0000 or 0 would be acceptable also

(See https://www.arduino.cc/en/Reference/IntegerConstants for notation reference.)
So your if statement would be very close to what you had originally wrote. 
if (invest == B0100)
{
   //code 
}

Using this method you cannot reference each bit in the same way as an array (ie invest[3]). Instead to view the 4th bit:
result = (invest && 0x08) >> 3;

To set the 4th bit you would need to write:
invest |= 0x08;    // ie. B1000

And to clear the 4th bit:
invest &= 0x07;    // ie. B0111


user31105: You cannot compare like that... you have to do it one by one (and check the length of the array).
if ((sizeof(invest) / sizeof(bool) == 4) &&
    (invest[0] == 0) && 
    (invest[1] == 1) &&
    (invest[2] == 0) &&
    (invest[3] == 0)) 
{
     ...
}

If you need to do such a compare often (with possibly different values), you of course can always write a dedicated function passing the array, and the array to check against and check the length and use a loop for checking all values.
Note that if invest is a boolean array, it's best to use false and true instead 0 and 1.

34518: <p>In my program I have the following lines of code:</p>

<pre><code>if (invest == {0, 1, 0, 0})
   {
      //code 
   }
</code></pre>

<p>However, upon attempting to compile the code, I receive the following error:</p>

<pre><code>exit status 1
expected ';' before '}' token
</code></pre>

<p>"Invest" is a bool array originally defined with`</p>

<pre><code>bool invest[] = {0, 0, 0, 0};
</code></pre>

<p>How can I prevent this error from ocurring?</p>
 19409: <p>Unfortunately you cannot do that.</p>

<p>In addition to Michel Keijzers, another possible way is to use binary manipulation of an integer.</p>

<p>Your declaration of the variable would look like this:</p>

<pre><code>unsigned int invest = 0x00;    // B0000 or 0 would be acceptable also
</code></pre>

<p>(See <a href="https://www.arduino.cc/en/Reference/IntegerConstants" rel="nofollow noreferrer">https://www.arduino.cc/en/Reference/IntegerConstants</a> for notation reference.)<br>
So your <code>if</code> statement would be very close to what you had originally wrote. </p>

<pre><code>if (invest == B0100)
{
   //code 
}
</code></pre>

<p>Using this method you cannot reference each bit in the same way as an array (ie <code>invest[3]</code>). Instead to <strong>view</strong> the 4th bit:</p>

<pre><code>result = (invest &amp;&amp; 0x08) &gt;&gt; 3;
</code></pre>

<p>To <strong>set</strong> the 4th bit you would need to write:</p>

<pre><code>invest |= 0x08;    // ie. B1000
</code></pre>

<p>And to <strong>clear</strong> the 4th bit:</p>

<pre><code>invest &amp;= 0x07;    // ie. B0111
</code></pre>
 31105: <p>You cannot compare like that... you have to do it one by one (and check the length of the array).</p>

<pre><code>if ((sizeof(invest) / sizeof(bool) == 4) &amp;&amp;
    (invest[0] == 0) &amp;&amp; 
    (invest[1] == 1) &amp;&amp;
    (invest[2] == 0) &amp;&amp;
    (invest[3] == 0)) 
{
     ...
}
</code></pre>

<p>If you need to do such a compare often (with possibly different values), you of course can always write a dedicated function passing the array, and the array to check against and check the length and use a loop for checking all values.</p>

<p>Note that if invest is a boolean array, it's best to use false and true instead 0 and 1.</p>
