> Now I am near a solution, something like this:
Well, this isn't a C language user group so I'll be brief. Here's the
outline of how I would do it.
Read entire file into memory
Add a terminating NUL (because sometimes text files don't have an ending NL)
Walk through the buffer char by char, sa
Now I am near a solution, something like this:
(doesnot yet have error checking everywhere, no get_line() so far, ...)
somewhere in program:
#include "preload.h"
int n_preload_file1, n_preload_file2;
int data = 0;
n_preload_file1 = preload_file("file1.txt");
n_preload_file2 = preload_file("f
The function I am writing right now will return already a zero
terminated string.
I dont know how to do it without a 0-termination. Maybe with length
variables? Not good...
A DOS line ends with 0x0D 0x0A, my function "cuts" this by overwriting
the 0x0D with a 0. Otherwise I cant use string f
> I just found that the Newlib library as included in the gcc-ia16
> toolchain does happen to implement fmemopen( ) (and several other POSIX
> functions as well).
>
> However, Open Watcom's C library does not have this function.
>
> I suppose, if a `FILE *' is not absolutely needed, then one ca
the stream */
int mode;
char unbuf[8]; /* The buffer for 'unbuffered' streams */
struct __stdio_file * next;
};
(example from dev86/bcc)
Nils
Forwarded Message
Subject:
Re: [Freedos-user] Preloading text files in C
Date:
Thu, 10 Jan 201
Hi Ken and TK Chia,
fmemopen looks very good, but sadly not available in Watcom. This is not
a big problem, rewriting the code to use buffers is not that much work.
I am using a own putc/puts-function-pair, which directly writes to video
memory. This lets me easily change it to another data sou
Hello Nils, hello Ken,
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?
No, fgets wants a FILE *, which is a pointer to a
> 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
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 i