title: How to check if element is included in array with arduino?
body: <p>I have an array called numbers and I want to test if a certain number is included in that array.</p>
  
  <pre><code>void loop(){
    if (arrayIncludeElement(numbers, mynumber)){
      // Do something
    } else {
      // Do something else
    }
  }
  </code></pre>
  
  <p>I have written a version of the <em>arrayIncludeElement</em> function, but it don't seem to work.</p>
  
  <pre><code>boolean arrayIncludeElement(array, element) {
    for (int i = 0; i &lt; sizeof(array); i++) {
      if (array[i] == element) {
        return true;
      }
    }
    return false;
  }
  </code></pre>
  
  <p><strong>ERROR MESSAGES</strong></p>
  
  <ul>
  <li>sketch:5: error: 'array' was not declared in this scope</li>
  <li>sketch:5: error: 'element' was not declared in this scope</li>
  <li>sketch:5: error: initializer expression list treated as compound
  expression</li>
  <li>sketch:3: error: redefinition of 'boolean arrayIncludeElement'</li>
  <li>sketch:5: error: 'boolean arrayIncludeElement' previously defined
  here</li>
  <li>sketch.ino: In function 'void loop()':</li>
  <li>sketch:11: error: 'arrayIncludeElement' cannot be used as a function</li>
  <li>sketch.ino: At global scope:</li>
  <li>sketch:16: error: redefinition of 'boolean arrayIncludeElement'</li>
  <li>sketch:5: error: 'boolean arrayIncludeElement' previously defined
  here</li>
  <li>sketch:16: error: 'array' was not declared in this scope</li>
  <li>sketch:16: error: 'element' was not declared in this scope</li>
  </ul>
  
  <p><strong>EDIT</strong>
  I updated the function to this.</p>
  
  <pre><code>boolean arrayIncludeElement(int array[], int element);
  boolean arrayIncludeElement(int array[], int element) {
    for (int i = 0; i &lt; (sizeof(array)/4); i++) {
      if (array[i] == element) {
        return true;
      }
    }
    return false;
  }
  </code></pre>
  
  <p>But now I get this error</p>
  
  <ul>
  <li>sketch.ino: In function 'void loop()':</li>
  <li>sketch:8: error: 'arrayIncludeElement' was not declared in this scope</li>
  <li>sketch:10: error: expected `;' before '}' token</li>
  </ul>
  
  <p><strong>Line 8</strong> being this</p>
  
  <pre><code>if (arrayIncludeElement(numbers, 5){
  </code></pre>
  
  <p>and <strong>Line 10</strong> being this</p>
  
  <pre><code>} else {
  </code></pre>