#include "func_test_io.h" #include #include #include #include //-----[ func_test_io ]--------------------------------------------------------- bool func_test_io() { /* { FILE * file; const char * filename = "files/write.txt"; const char * string = "La technologie au service de la paix\n"; printf("Test write in file\n"); if ((file = fopen (filename,"w")) == NULL) printf("fopen : Ko - errno : %x - %s\n",errno,strerror(errno)); else { printf("fopen : Ok\n"); if (fputs (string,file) == EOF) printf("fputs : Ko - errno : %x - %s\n",errno,strerror(errno)); else printf("fputs : Ok\n"); if (fputs ("La paix par le pouvoir\n",file) == EOF) printf("fputs : Ko - errno : %x - %s\n",errno,strerror(errno)); else printf("fputs : Ok\n"); if (fclose (file) == EOF) printf("fclose : Ko - errno : %x - %s\n",errno,strerror(errno)); else printf("fclose : Ok\n"); } } */ { FILE * file; const char * filename = "files/read.txt"; char * string = (char *) malloc (100); printf("Test read in file\n"); if ((file = fopen (filename,"r")) == NULL) printf("fopen : Ko - errno : %x - %s\n",errno,strerror(errno)); else { printf("fopen : Ok\n"); string = fgets (string,50,file); while (string != NULL) { print (string); printf("fputs : %s\n",string); string = fgets (string,50,file); } print(string); if (fclose (file) == EOF) printf("fclose : Ko - errno : %x - %s\n",errno,strerror(errno)); else printf("fclose : Ok\n"); } } return true; }// end fct func_test_io