Warning:  Undefined array key "view" in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 2
Warning:  Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 47
Warning:  Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 48
Warning:  Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 49
Warning:  Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 50
Warning:  Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 51
/**
 *  conteggia il numero di byte contenuti in un file specificato
 *  sulla riga di comando
 */
#include 
#include 
#include 
#include 
#define BUFSIZE 1024
int main(int argc, char *argv[]) {
    int fd, size;
    int total = 0;
    char buffer[BUFSIZE];
    if (argc < 2) {
        printf("utilizzo: %s \n", argv[0]);
        exit(1);
    }
    // apre il file sorgente in sola lettura
    if ((fd = open(argv[1], O_RDONLY)) == -1) {
        perror(argv[1]);
        exit(1);
    }
    // copia tutti i dati in memoria per conteggiare la dimensione
    do {
        if ((size = read(fd, buffer, BUFSIZE)) == -1) {
            perror(argv[1]);
            exit(1);
        }
        total += size;
        printf("ho letto %d byte\n", size);
    } while (size > 0);
    printf("La dimensione totale e' di %d byte\n", total);
    close(fd);
}