[ create a new paste ] login | about

Link: http://codepad.org/25McwrMU    [ raw code | output | fork ]

C, pasted on May 19:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  const char *date = "11/22/99";
  int m, d, y;
  
  if (sscanf(date, "%02d/%02d/%02d", &m, &d, &y) == 3)
    printf("Month: %d, Day: %d, Year: %d", m, d, y);
  else
    printf("Invalid date format");

  return 0;
}


Output:
1
Month: 11, Day: 22, Year: 99


Create a new paste based on this one


Comments: