#include "main.h" //====================================================================== int main(int argc, char **argv) { char buf[13] = "hello world\n"; int res; if ( argc != 2 ) { printf("usage : ./prog05_file_high_level output_file \n"); return 1; } FILE *fd = NULL; fd = fopen( argv[1], "wr"); if( fd == NULL ) { perror("open error"); return 1; } int ok = fprintf(fd, buf); if ( ok == -1 ) { perror("write error"); return 1; } res = 5 + 8; ok = fprintf(fd, "sum = %d\n", res); if ( ok == -1 ) { perror("write error"); return 1; } ok = fprintf(stdout, "I write on the standart output \n"); // Same as printf if ( ok == -1 ) { perror("write error"); return 1; } ok = fclose(fd); if ( ok == -1 ) { perror("close error"); return 1; } return 0; } //^^^^^^^^^^^^^^^^^^^^^^^^^^ EOF ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^