Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. void pyExe(){
  2. /**arquivo .dat e arquivo .txt, respectivamente**/
  3. FILE *fp, *fp1;
  4. /**struct para leitura dos dados contendo os eventos**/
  5. struct evento *display = (struct evento *)malloc(sizeof(struct evento));
  6.  
  7. char buffer[48];
  8. char email_events[] = {"dd_mm.txt"};//nome do arquivo.txt
  9. char msg[]={"Nao ha eventos disponiveis para hoje!n"};
  10. int count=0;
  11. time_t rawtime;
  12. time(&rawtime);
  13. struct tm timenow = *localtime(&rawtime);
  14. strftime(buffer, 48, "%d_%m", &timenow);
  15. fp = fopen(file_name, "rb");
  16. fp1 = fopen(email_events, "w");
  17. if(strcmp(buffer, email_events)!=0){
  18. strcpy(email_events, buffer);
  19. while(fread(display, sizeof(struct evento), 1, fp)==1){
  20. if (feof(fp) || fp==NULL){
  21. break;
  22. }
  23. else if(display->dia==timenow.tm_mday && display->mes==timenow.tm_mon+1){
  24. fwrite(display, sizeof(struct evento), 1, fp1);
  25. fprintf(fp1, "%s", "n");
  26. count++;
  27. }
  28. }
  29. }
  30. if(count==0){
  31. fprintf(fp1, "%s", msg);
  32. }
  33. fclose(fp);
  34. fclose(fp1);
  35. }
  36.  
  37. strcpy(email_events, buffer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement