title: How do i match a username with password in c?
body: <p>Iwant to write a login program. I want every username to match its specific password. For example, the username &quot;Asma&quot; should only be logged in with the password &quot;Hello123&quot; not with &quot;Welcome&quot;.</p>
  <p>But somehow when I enter every username and password from the string array, it says &quot;Logged in successfully&quot;. How do I make every username to match its own password? Also, how do I ask for a valid input again when the username and password are both incorrect?</p>
  <p>Here is my code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main(void)
  {
      char username[10];
      char password[10];
  
      printf(&quot;Enter your username: &quot;);
      scanf(&quot;%s&quot;, username);
  
      printf(&quot;Enter your password: &quot;);
      scanf(&quot;%s&quot;, password);
  
      if(strcmp(username,&quot;Asma&quot;) == 0 || strcmp(username,&quot;Iffat&quot;) == 0 || strcmp(username,&quot;Kamal&quot;) == 0 ){
      if(strcmp(password,&quot;Hello123&quot;) == 0 || strcmp(password,&quot;Welcome&quot;) == 0  || strcmp(password,&quot;fr1324&quot;) == 0 ){
  
          printf(&quot;Logged In Successfully&quot;);   
  
          }else{
      printf(&quot;Incorrect username or password, please try again! &quot;);
  }
  
  }else{
  
  printf(&quot;Incorrect username or password, please try again! &quot;);    
  }
  </code></pre>