Replacing a Row in a Memory File

Besides adding new text lines to a memory file, function mf_rowrpl() can be used to replace existing text in a memory file. If you call mf_rowrpl() for a row in the memory file which already exists, the string for that row is replaced.

You do not need to worry about managing memory when you replace existing file contents. If the row specified in mf_rowrpl() is not empty, the memory previously allocated to hold the contents of the row is freed by mf_rowrpl().

The call:

mf_rowrpl("New string", 5, mfp);

will release the memory allocated for row 5, create a new MFLINE structure initializing it for the new string, and placing a pointer to this MFLINEPTR structure in row 5 of the memory file array.


Home Contents Previous Next