title: C why is this for loop not executing when its conditions are met?
body: <p>I have a for loop which is used to find the nearest helicopter to a specific ship in danger.</p>
  
  <p>The problem I am having is I need to ignore LifeBoats from my search (these have the type of <code>L</code> which is a single char in a struct) and only focus on Helicopters, represented by a <code>H</code> which is a single char in a struct.</p>
  
  <p>The problem I have is that when I have this for loop:</p>
  
  <pre><code>closest_index = 0;
  
  for (j = 0; j &lt; asset_size; j++) {
          printf("type : %c \n", (assets + j)-&gt;type);
          if ((assets + j)-&gt;type == 'H') {
              if (((assets + j) -&gt;distance_from_mayday) &lt; ((assets + closest_index) -&gt;distance_from_mayday)) {
                  closest_index = j;
                  printf("closest_index heli = %d \n", closest_index);
  
              }
          }
      }
  </code></pre>
  
  <p>It definitely gets called, I added the line:</p>
  
  <pre><code> printf("type : %c \n", (assets + j)-&gt;type);
  </code></pre>
  
  <p>just before the comparison, and it produces this result in the console:</p>
  
  <pre><code>type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : L 
  type : H 
  type : H 
  type : H 
  type : H 
  type : H 
  type : H
  </code></pre>
  
  <p>As you can see there is values of <code>H</code> so I don't understand why this for loop is not executing as intented, any ideas?</p>