Guest User

bozza_programma

a guest
Nov 4th, 2011
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main ( void )
  5.  
  6. {
  7.  
  8. /* acquisisco i 3 file di ore(file a.txt), minuti(file b.txt), e secondi(file c.txt) che indicano l'ora in cui รจ stata inserita la periferica usb */
  9. int system ("tail -1 /var/log/messages | cut -b 8-9 > a.txt");
  10. int system ("tail -1 /var/log/messages | cut -b 11-12 > b.txt");
  11. int system ("tail -1 /var/log/messages | cut -b 14-15 > c.txt");
  12.  
  13. /* leggo il contenuto dei file appena creati */
  14. FILE *stream0 *stream1 *stream2
  15. stream0=fopen("c.txt", "r");
  16.  
  17. int i; /* variabile per memorizzare la stringa letta */
  18. i = atoi (
  19. stream1=fopen("b.txt", "r");
  20. stream2=fopen("a.txt", "r");
  21. again: /* creo un goto per mantenere aggiornato il sistema di controllo del cronometro */
  22.  
  23. /* adesso acquisisco l'ora attuale e reindirizzo i valori nei 3 file (a, b1, c1) come prima */
  24. int system ("date | cut -b 18-19 > a1.txt");
  25. int system ("date | cut -b 21-22 > b1.txt");
  26. int system ("date | cut -b 24-25 > c1.txt");
  27.  
  28. /* dichiaro lo stream e la funzione fopen */
  29. FILE *stream *fopen();
  30.  
  31. /* apre lo stream del file */
  32. stream = fopen("c1.txt", "r");
  33.  
  34. /* controlla se il file viene aperto */
  35. if ((stream = fopen("a.txt", "r")) == NULL)
  36.  
  37. {
  38. printf("Cannot open file");
  39. exit(1);
  40. }
  41.  
  42. goto again;
  43.  
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment