Advertisement
hocikto19

parent lock part 1

Aug 1st, 2014
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <string.h>
  4. #define SUBOR "date.txt"
  5.  
  6. int main(){
  7.     time_t t = time(NULL);
  8.     struct tm tm = *localtime(&t);
  9.     int actDate, fileDate;
  10.     FILE *f;
  11.     actDate = tm.tm_mday;
  12.     f = fopen(SUBOR, "r");
  13.     fscanf(f, "%d", &fileDate);
  14.     fclose(f);
  15.     if (fileDate==actDate)
  16.         return 0;
  17.     else{
  18.         f = fopen(SUBOR, "w");
  19.         fprintf(f, "%d", actDate);
  20.         fclose(f);
  21.         if (tm.tm_wday == 0 || tm.tm_wday == 6)
  22.             return 1;
  23.         else
  24.             return 2;
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement