title: Asking the user to re-run the program or exit in C
body: <p>I've been trying to create a bot to grab the date, time, and several more operations.</p>
  <p>(This is my first question ever here, and I'm a bad explainer so bear with me please, hopefully you would understand me if not please don't tear me apart for lacking knowledge :)</p>
  <p>I'm prompting the user to enter &quot;What's the &lt;time/date&gt;?&quot; it outputs the answer, then the program ends.
  But I don't want the program to end, I want it to prompt the user again whether to exit or re-run the program, if the user inputs 'Y' the code gets repeated, 'N' ends the program.</p>
  <p>This is my code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;time.h&gt;
  
  int main()
  {
      int hours, minutes, day, month, year;
      char user_req[50], user_prompt[3];
      
      time_t now;
      time(&amp;now);
      
      struct tm *local = localtime(&amp;now);
      
      hours = local-&gt;tm_hour;
      minutes = local-&gt;tm_min;
      day = local-&gt;tm_mday;
      month = local-&gt;tm_mon + 1;
      year = local-&gt;tm_year + 1900;
      
  
      printf(&quot;How may I help you?: &quot;);
      scanf(&quot;%[^\n]&quot;, &amp;user_req);
      
      if((strcmp (user_req, &quot;What's the time?&quot;) == 0) &amp;&amp; hours &lt; 12){
          
          printf(&quot;\nCurrent time is: %02d:%02dAM&quot;, hours, minutes);
  
      } else if((strcmp (user_req, &quot;What's the time?&quot;) == 0) &amp;&amp; hours &gt; 12 ){
          printf(&quot;\nCurrent time is: %02d:%02dPM&quot;, hours - 12, minutes);
  
      } else if(strcmp (user_req, &quot;What's the date?&quot;) == 0){
          printf(&quot;\nCurrent date is: %d/%02d/%02d\n&quot;, year, month, day);
      } else {
          printf(&quot;\nError, please try again and follow the specific format!&quot;);
      }
  
      printf(&quot;\nMay I help you again? (Y/N): &quot;);
      scanf(&quot; %c&quot;, &amp;user_prompt); 
      
      return 0;
  }
  </code></pre>
  <p>I have tried most of the answers here(Do-While, Goto, &amp; EOF, EOF seems to be the closest one to my case but I couldn't even import it into my piece of code since it's kinda overwhelming.):</p>
  <p><a href="https://stackoverflow.com/questions/34941692/ask-user-to-repeat-the-program-or-exit-in-c">Ask user to repeat the program or exit in C</a></p>
  <p><a href="https://stackoverflow.com/questions/16248841/how-to-use-a-loop-function-with-user-input-in-c">How to use a loop function with user input in C?</a></p>
  <p>I've encountered 2 <a href="https://i.stack.imgur.com/OmuqK.png" rel="nofollow noreferrer">bugs</a> with Do-While &amp; goto,</p>
  <ol>
  <li>After looping again, the output of the first operation is shown.</li>
  <li>After inputting 'Y' to re-run the program, instead of going to the prompt of &quot;How may I help you?&quot; it goes to the prompt of &quot;May I help you again? (Y/N):&quot;</li>
  </ol>
  <p>Is it possibly because the if statements are interfering with the loops or something?</p>