Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main ( void )
- {
- /* 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 */
- int system ("tail -1 /var/log/messages | cut -b 8-9 > a.txt");
- int system ("tail -1 /var/log/messages | cut -b 11-12 > b.txt");
- int system ("tail -1 /var/log/messages | cut -b 14-15 > c.txt");
- /* leggo il contenuto dei file appena creati */
- FILE *stream0 *stream1 *stream2
- stream0=fopen("c.txt", "r");
- int i; /* variabile per memorizzare la stringa letta */
- i = atoi (
- stream1=fopen("b.txt", "r");
- stream2=fopen("a.txt", "r");
- again: /* creo un goto per mantenere aggiornato il sistema di controllo del cronometro */
- /* adesso acquisisco l'ora attuale e reindirizzo i valori nei 3 file (a, b1, c1) come prima */
- int system ("date | cut -b 18-19 > a1.txt");
- int system ("date | cut -b 21-22 > b1.txt");
- int system ("date | cut -b 24-25 > c1.txt");
- /* dichiaro lo stream e la funzione fopen */
- FILE *stream *fopen();
- /* apre lo stream del file */
- stream = fopen("c1.txt", "r");
- /* controlla se il file viene aperto */
- if ((stream = fopen("a.txt", "r")) == NULL)
- {
- printf("Cannot open file");
- exit(1);
- }
- goto again;
- }
Advertisement
Add Comment
Please, Sign In to add comment