title: read from a formatted test file using fscanf() in c
body: <p>Here is the text file</p>
  
  <pre><code>Username:user1  Password:pass1
  Username:user2  Password:pass2
  </code></pre>
  
  <p>I want to read the username and password from the text. the problem is there is not way to change the format of the text. i tried to read but as there is not space between colon(:), it gives whole <code>username:user1</code> as string but i want only user1. i referred to <a href="https://stackoverflow.com/questions/26528212/using-fscanf-to-skip-a-string">this</a> question but it did not help as there is no space between colon.</p>
  
  <p>I tried :</p>
  
  <pre><code> while ((fscanf(fp,"Username:%s Password:%s",username,password))!=EOF)
  </code></pre>
  
  <p>but it gives many undefined characters after user1 and loop never ends.</p>