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
/**
* legge i primi 10 byte del file 'pippo.txt'
*/
#include
#include
#include
#include
#define DIM_BUFFER 1024
int main() {
int fd, n;
const char *name = "pippo.txt";
char buffer[DIM_BUFFER] = "testo molto lungo dentro il buffer";
if ((fd = open(name, O_RDONLY)) == -1) {
perror(name);
exit(1);
}
if ((n = read(fd, buffer, DIM_BUFFER - 1)) == -1) {
perror(name);
exit(1);
}
buffer[n] = '\0'; // buffer[n] = 0;
printf("ho letto: %s \n", buffer);
close(fd);
}