title: Check if strng value exist in struct array
body: <p>I have a struct where the user would enter a number of coordinates of their choosing and label each one. So if they select to enter 3 coordinate they need to label all 3 and give the coordinates. I can loop through all the data and verify if the label exist but I can not assign the struct label with the value if none are found.</p>
  <p>Here is my code</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;math.h&gt;
  #include &lt;string.h&gt;
  
  /*Stuct link list */
  struct node
  {
      double xCoord; 
      double yCoord;
      char label[30];
  };
  
  int checkLabel(char* receivedlabel, int coordSize, struct node coord[coordSize])
  {
     
      int i,j;
       
       
      if (coordSize == 0)
      {
          
      }
      else
      {
      
      for(i = 0; i&lt;coordSize; i++)
      {
          
           if(strcmp(coord[i].label, receivedlabel)==0)
           {
              j = 0;
              break;
           }
           else 
           {
              j = 1;
           }
  }   
  }
      
      return j;
  }
  int main() {
      int i, numOfCoords, j, k;
      double distance;
      double closest = 0;
      double farthest = 0;
      char label[30];
       do //Get the amount of coordinates to enter greater than 2
      {
          printf(&quot;How many coords do you want to enter?\nPlease enter more than 2:&quot;);
          scanf(&quot;%d&quot;, &amp;numOfCoords);
          
      }while(numOfCoords &lt;=2);
      
      struct node coords[numOfCoords];
      
      for(i = 0; i &lt; numOfCoords; i++ )
      {
          do
          {
          printf(&quot;Please Enter a X Coordinate:&quot;);
          scanf(&quot;%lf&quot;, &amp;coords[i].xCoord);
          printf(&quot;Please Enter a y coordinate:&quot;);
          scanf(&quot;%lf&quot;, &amp;coords[i].yCoord);
          }while(coords[i].xCoord&lt;0 || coords[i].yCoord&lt;0);
          if(i==0)
          {
              printf(&quot;Please Enter a Label:&quot;);
          scanf(&quot;%s&quot;, &amp;coords[i].label);  
          }
          else
          {
          do
          {
          printf(&quot;Please Enter a Label:&quot;);
          scanf(&quot;%s&quot;, &amp;label);
          
          k = checkLabel(label,i, coords);
          if(k == 1)
          {
              *coords[i].label = label;
              }   
          }while(k==0);
          
              
          }
          
      }
      printf(&quot;\n&quot;);
        for(i = 0; i &lt; numOfCoords-1; i++ )
      {
          for(j = 1; j &lt; numOfCoords; j++)
          {
              
              distance = sqrt(pow(coords[i].xCoord - coords[j].xCoord,2) + pow(coords[i].yCoord - coords[j].yCoord,2)); //Calculate Distance
              if(distance == 0) //If distance equal 0 output no info
              {
                  
              }
              else
              {
                //Print out the distance of all coordinates entered   
                printf(&quot;The distance between %s:[%lf,%lf] and %s:[%lf,%lf] is %lf\n&quot;, coords[i].label, coords[i].xCoord, coords[i].yCoord,coords[j].label, coords[j].xCoord, coords[j].yCoord, distance);     
               if(j==1 &amp;&amp; i==0)
            {
              //Set the closet and furthest distance to the first calculated distance
              closest = distance; 
              farthest = distance;
              
            } 
            else
            {
              if(distance &gt; farthest)//If distance is larger than current furthest set furthest equal to current distance
              {
                farthest = distance;
                  
              }
              if(distance &lt; closest) //If distance is less than closet set closet equal to current distance
              {
                  closest = distance;
              }
              }
              
          }
          
      }
      
  }
  printf(&quot;The closet coordinate is %lf and the furthest is %lf\n&quot;, closest, farthest);//Display closest and farthest distance
      return 0;
  }
  </code></pre>