title: How to compare a given string with a result
body: <p>I'm very new to this and to C programming. It's my first year and things are not very clear for me. Hopefully I can get better very soon.</p>
  
  <p>I have a code here where i input a number and I get results based on the table I have below.
  I would like to know: If i have a given string (in the code it's: test[7]="2 B 1 C")
  How can I compare the result i have to this string and see if it's the same to print=good?</p>
  
  <p>it's very hard to explain so please let me know if i'm not clear with my question. You can test the code to see how it works.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  void initialize(int poss[1296][4]);
  
  int main()
   {
    int table[1296][4];
    char str[5];
    char tmp[5];
  
    int i, j, k;
    int bull = 0;
    int cow = 0;
    char test[7]={"2 B 0 C"};
  
    initialize(table);
    printf("Enter 4 digits: ");
  
    scanf("%s", str);
  
    for (i=0; i&lt;1296; i++)  // building this table
    {
      strcpy(tmp, str);   // copying string
  
      for (j=0; j&lt;4; j++)
      {
          for (k=0; k&lt;4; k++)
          {
              if (table[i][j]==tmp[k]-'0' &amp;&amp; j==k)    // gets the string as an integer
              {
                  tmp[k] = -1;
                  bull++;
                  break;
              }
              else if (table[i][j]==tmp[k]-'0' &amp;&amp; j!=k)
              {
                  tmp[k] = -1;
                  cow++;
                  break;
              }
          }
      }
  
      printf ("%d B %d C\n\n", bull, cow);
      bull = 0;
      cow = 0;
    }
  }
  
  //------------------------------------TABLE---------------------------------//
  
  void initialize(int poss[1296][4])
   {
  int i=0;
  int j, k=0;
  int m;
  
  while (i&lt;=5)
  {
      for (j=0; j&lt;216 ; j++)
      {
          poss[k][0]=i;
          k++;
      }
      i++;
    }
  
    k=0;
    i=0;
    j=0;
  
    while (k&lt;1296)
    {
      for (m=0; m&lt;6; m++)
       {
          for (j=0; j&lt;6; j++)
            {
              for (i=0; i&lt;36 ; i++)
                {
                  poss[k][1]=j;
                  k++;
                }
            }
        }
    }
  
    k=0;
    i=0;
    j=0;
    m=0;
  
    while (k&lt;1296)
     {
      for (j=0; j&lt;6; j++)
      {
          for (i=0; i&lt;6; i++)
          {
              poss[k][2]=j;
              k++;
          }
      }
  
    }
  
    k=0;
    i=0;
    j=0;
    m=0;
  
    while (k&lt;1296)
    {
      for (i=0; i&lt;6; i++)
        {
          poss[k][3]=i;
          k++;
        }
    }
   }
  </code></pre>