title: Undeclared variable in function
body: <pre><code>//Function to store select_field
  void store_field(int num_fields, unsigned long *lengths, 
      MYSQL_ROW row, char elect_type[10][100]) 
  {
      //Storing select_field below
      int i,j,k,g;
      for( i=1;i &lt; num_fields;i=i+10)
      { 
          // i+10 so that loop is executed one time only, 
          // i=1 bcoz 2nd entry is select_type
          for (j=0;j&lt;lengths[i];j++)
          {
              if (row[i] != NULL)
              {
                  select_type[k][j] = *row[i];
                  row[i]++; 
              }
  
              if (row[i] == NULL) 
              { 
                  select_type[k][j]= '\0';
                  printf ( "NULL\n");
                  break; // row[i] is null for fields containing NULL
              }
          }
          for (j;j&lt;100;j++)
          {
              select_type[k][j]='\0';
          } 
              // setting every other empty field in current row 
              // of select_type to NULL   
      }
      k++; 
  }   
  g = k; //HERE I AM GETTING THE ERROR 
  for (k;k&lt;10;k++){for(j=0;j&lt;100;j++)
  {
      select_type[k][j]='\0'; 
  }
  }    
  </code></pre>
  
  <p>I have already declared <code>k</code> in the function but I am getting the error.</p>