title: In scanf, how can I ignore one of two, but not both characters?
body: <p>I'm fairly new to C, and I'm writing some code which will allow the user to enter the date in the form dd/mm/yyyy OR dd-mm-yyyy. I can't figure out how to get scanf to ignore the dash or slash, but not both. I need the code to recognise negative numbers after a slash is entered as well. At the moment, the program just thinks it's a dash and ignores it.</p>
  
  <pre><code>    int dd1, mm1, yyyy1;
      char str [3];
      scanf("%d %[-/] %d %[-/] %d", &amp;dd1, str, &amp;mm1, str, &amp;yyyy1);
  </code></pre>
  
  <p>Any help will be greatly appreciated!</p>