title: Comparing two arrays in C, element by element
body: <p>I have been cracking my head at achieving something very simple in C in order to make my one of the programs (not written by me) in our computational physics project more dynamic:
  comparing two different arrays element by element in an if conditional.</p>
  <pre><code>#include &lt;math.h&gt;
  #include &lt;stdio.h&gt;
  #include &quot;header.h&quot;
  const int nParam = 10;
  double a[nParam], a_tmp[nParam];
  double values[10000];
  
  double FitParam(double x){
      int xindex;
      double value;
  
      xindex=(int) x;
  
      if (a_tmp[1]==a[1] &amp;&amp; a_tmp[2]==a[2] &amp;&amp; a_tmp[3]==a[3] &amp;&amp; a_tmp[4]==a[4]){ 
          value=values[xindex];
          return(value);
      }
  
  // code continues... (very long subroutine and there is recursion for
  // the subroutine so this if statement above is very important).
  </code></pre>
  <p>The array <code>a[ ]</code> has a varying number of significant elements every time we run our program; for example, right now, we are using this subroutine for only elements <code>[1]</code> through <code>[4]</code>. However, in other cases, we will want to have fewer or more elements, say,  up to 3 elements or up to 5 elements, respectively.</p>
  <p>So essentially, I want to be able to <strong>rewrite the if statement above so that it is dynamic... in other words, if there are N elements considered, then it will do</strong>:</p>
  <p><code>if (a_tmp[1]==a[1] &amp;&amp; ... &amp;&amp; a_tmp[N]==a[N]){}</code></p>
  <p>So this if conditional should vary whenever our number N of elements of interest is changed (N is defined as a #define in the header of this file, which I just named header.h).</p>
  <p>I would greatly appreciate your support on this task. Thank you.</p>