> Hi, > I have a short question about preloading text files for a user interface. > > I have x buttons on screen and for each button there is a description > shown on screen, once this button is selected. > > For now I am fopen()/fgets()/fclose()ing it on every selection change. > When run from floppy this is very slow and noisy. > > I thought about preloading it to a buffer, but maybe there is a better > way. That's why I am asking here. > My idea now looks something like this: > > char *ptrarray[10]; > > ptr_array[0] = malloc(size_of_textfile); > copy_to(file0, ptr_array[0]; > ptr_array[1] = malloc(size_of_textfile); > copy_to(file1, ptr_array[1]; > > ... > > Can I still use fgets() on these pointers once the file has been loaded > there? > > > Thanks, > > Nils
No, fgets wants a FILE *, which is a pointer to a stream, not a char *. If you are not able to rewrite the program to process the buffer directly, forgetting about fgets(), there is fmemopen() which returns a FILE * given a string. But it may not be implemented in your C library. https://pubs.opengroup.org/onlinepubs/9699919799/functions/fmemopen.html _______________________________________________ Freedos-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freedos-user
