fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct data {
  5. int zi, luna, an;
  6. } Data;
  7.  
  8. int main(void){
  9. FILE *pf = stdin;//for ideone, fopen("data.txt", "r");
  10. if(pf == NULL){
  11. perror("fopen");
  12. return -1;
  13. }
  14. Data *d;
  15. int n;
  16. fscanf(pf, "%d", &n);
  17. d = calloc(n, sizeof(Data));
  18. if(d == NULL){
  19. perror("malloc");
  20. return -2;
  21. }
  22. for(int i = 0; i < n; i++){
  23. if(fscanf(pf, "%d/%d/%d", &d[i].zi, &d[i].luna, &d[i].an)!=3) break;
  24. printf("%d/%d/%d ", d[i].zi, d[i].luna, d[i].an);
  25. }
  26. fclose(pf);
  27. free(d);
  28. }
Success #stdin #stdout 0s 2300KB
stdin
3
2/3/2011
2/2/2012
2/2/2016
stdout
2/3/2011 2/2/2012 2/2/2016