title: Query date from user, use today's date if user press enter
body: <p>In a C-program I am trying to query user for a date which shall be put into a char-array in a structure (<em>pIndex->startDate</em>). If the date is today's date the user should only need to press enter - and if the date is some other, the user will have to type it in. </p>
  
  <p>The input is done by fgets. What I think is that I'll check if the user input is equal  '\n' – in that case I set the array equal to today's date. If not, the array will be whatever the user typed.</p>
  
  <p>To find the date (in general), I use:</p>
  
  <pre><code>time_t now = time(NULL);
  struct tm *t = localtime(&amp;now);
  </code></pre>
  
  <p>..and I have a temp char-array for the if-statement:</p>
  
  <pre><code>char temp_date[11]="2014-01-01";  //initialized with something, guess there is a better solution
  </code></pre>
  
  <p>I have tried the following:</p>
  
  <pre><code>    printf("Enter start date (press Enter for todays date) &gt; ");
      fgets(pIndex-&gt;startDate, MAXDATE, stdin);
          if (pIndex-&gt;startDate=='\n'){
          sprintf (temp_date, "%d-%02d-%02d", t-&gt;tm_year+1900, t-&gt;tm_mon+1, t-&gt;tm_mday);
              (pIndex-&gt;startDate)==temp_date;
          }
  /*Check the result*/
      printf("CHECK TEMP_DATE: %s\n&gt; ",temp_date);
      system("pause");
  </code></pre>
  
  <p>However, the only thing that appears in the output is the value char temp_date was initialized with: <em>2014-01-01</em></p>
  
  <p>Is this a wrong approach? Anyone knows a better (working) way?</p>