title: finding if an array is a sub-sequence of another array
body: <p>Let us assume that I have those two <code>arrays</code>, <code>int array[15] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}</code> and <code>int s_array[15] = {1,2,3,4,5}</code></p>
  
  <p>*note that I am aware that <code>s_array[]</code> is set to 15 but only has 5 elements</p>
  
  <p>in the following part of my code I'd like to check if <code>s_array[]</code> is a sub-sequence of <code>array[]</code>, that means that whatever values are stored in <code>s_array[]</code> are also stored in <code>array[]</code>, and in the same order. That means that <code>{3,5,4}</code> is not a sub-sequence whereas <code>{3,4,5}</code> is.</p>
  
  <p>this is the part of the code (in which I think the problem lies). <code>j</code> is the number of in <code>s_array[]</code>. the whole code will be shown down below</p>
  
  <pre><code>            for( i = 0; i &lt; 15; i++ ){
              if( s_array[0] == array[i] ){ /*if the first element of the s_array is not 
                                             available then it is not a sub-sequence and 
                                              there is no need to check the rest */ 
                  for( Bcount = 1; Bcount &lt; ( j - 1 ); Bcount++ ){
                      if( s_array[Bcount] == array[Bcount + i])
                          counter++;
                      else{
                          printf( "B is not a sub-sequence of A." );
                          break;
                      }
                  }
                  if( j == counter ){
                      printf( "B is a sub-sequence of A." );
                      break;
                  }
              }
              else
                  continue;
          }
  </code></pre>
  
  <p>The whole code for whoever is interested or if it will help understand better</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(){
      int array[15], s_array[15], i = 0, j = 0, Bcount = 1, counter = 1;
      printf( "Please enter a sequence A: " );
      while(i &lt; 15  &amp;&amp; scanf("%d", &amp;array[i]) == 1) {
            //input for array[], will always have 15 elements
          i++;
          if( i == 15){
              printf( "Please enter a sequence B: " );
              while(j &lt; 15  &amp;&amp; scanf("%d", &amp;s_array[j]) == 1) {
                  //input for s_array, will have somewhere between 1 and 15 elements
                  j++;
              }
              for( i = 0; i &lt; 15; i++ ){
                  if( s_array[0] == array[i] ){
                      for( Bcount = 1; Bcount &lt; ( j - 1 ); Bcount++ ){
                          if( s_array[Bcount] == array[Bcount + i])
                              counter++;
                          else{
                              printf( "B is not a sub-sequence of A." );
                              break;
                          }
                      }
                      if( j == counter ){
                          printf( "B is a sub-sequence of A." );
                          break;
                      }
                  }
                  else
                      continue;
              }
              return 5;
          }
      }
      return 0;
  }
  </code></pre>