title: Compare Strings with if statenent in C
body: <p>I'm a beginner in c programming and i'have come to a point (pretty ridiculous) that i'm stuck at an if statement between two strings.</p>
  
  <p>In this program, i want the user to input a lesson of a student saved in a structure, then it should search for students with the same lesson and print them on screen. </p>
  
  <p>My problem is at <code>if statement</code>, for some reason (memory address maybe?) when i type the same characters, it sees them for different strings.
  The code just "skips" the if part. Although it works when i declare <code>if(record[0].lesson!="maths")</code> for instance.</p>
  
  <p>i have tried lots of things such as <code>strcmp</code>, </p>
  
  <p><code>if (record[0].lesson==record[1].lesson)</code></p>
  
  <p><code>if(record[0].lesson=="maths")</code>... and other. </p>
  
  <p>I would highly appreciate it if you could help me. thank you very much.</p>
  
  <pre><code># include &lt;stdio.h&gt;
  # include &lt;string.h&gt;
  typedef struct student{
      char name[10];
      char lesson[10];
  }students;
  
  int main()
  {
      students record[10];
      char less;
      strcpy(record[0].name,"James");
      strcpy(record[0].lesson,"maths");
      strcpy(record[1].name,"John");
      strcpy(record[1].lesson,"maths");
      strcpy(record[2].name,"Harry");
      strcpy(record[2].lesson,"C/C++");
      printf("Give Lesson\n");
      scanf("%s",less);
      for(int i=0;i&lt;3;i++){
      if(less==record[i].lesson)
      printf("%s\n",record[i].name);}
  
  
      return 0;
  }
  </code></pre>