title: Reading in C using fscanf
body: <p>I've did my research and did several attempts but none came to work and I don't know why because I'm almost the same as a begginer.</p>
  <p>From a text file:</p>
  <blockquote>
  <p>Hello;20</p>
  <p>Wait;10</p>
  <p>Please;5</p>
  </blockquote>
  <p>I want to save the first word &quot;Hello&quot; into a variable and the number 20 in another one.
  The same goes for the rest of the lines.</p>
  <p>I have this:</p>
  <pre><code>int main()
  {
  
  FILE* file;
  char fileName[50];
  int seconds;
  
  file = fopen(&quot;order.txt&quot;,&quot;r&quot;);
  
  while(fscanf(file,&quot;%s;%d&quot;,&amp;fileName,&amp;seconds) != EOF)
  {
  
  printf(&quot;%s&quot;,fileName);
  printf(&quot;\n&quot;);
  sleep(seconds);
  
  }
              
  fclose(file);
  }
  </code></pre>
  <p>I've tried to change things inside fscanf but nothing came to work, the output is the following:</p>
  <blockquote>
  <p>Hello;20</p>
  <p>Wait;10</p>
  <p>Please;5</p>
  </blockquote>
  <p><strong>----------------------</strong></p>
  <p>I've tried something new (seems like I should edit this instead of creating an answer) which was getting the content from a file like this:</p>
  <p><strong>order.txt</strong></p>
  <blockquote>
  <p>hello.txt;20</p>
  <p>wait.txt;10</p>
  <p>please.txt;5</p>
  </blockquote>
  <p><strong>I want to get the file name one by one, open it, show the content for X time, all for the 3, which lead to me:</strong></p>
  <pre><code>orderFile = fopen(&quot;order.txt&quot;,&quot;r&quot;);
  
          while(fscanf(orderFile,&quot;%49[^;];%d&quot;,fileName,&amp;seconds) == 2)
          {
              contentFile = fopen(fileName,&quot;r&quot;);
  
              while(fscanf(contentFile,&quot;%[^\t]&quot;,textContent) == 1)
              {
                  printf(&quot;%s\n&quot;, textContent);
              }
              
              sleep(seconds);
              
              fclose(contentFile);
          }
  
          fclose(orderFile);
  </code></pre>
  <p>Yet, it only shows the first file content, wait 20 seconds, and then it ends the program. I want it to show the content for the whole files. How can I do it?</p>