Modifying a Row in a Memory File

If you wish to modify a row in a memory file, (1) get the contents of the desired row to a buffer, (2) make the modifications in the string buffer, and (3) use mf_rowrpl() to write the contents of the buffer back to the file.

The following example shows how to get the contents of the memory file row, change the contents of a row to all uppercase, and place it back in the memory file. In this example, which does not change the length of the file line, it would have been possible to do the operations directly on the string using mf_rowp(), rather than using a buffer. The example uses a buffer to illustrate the procedure that is required when the operation increases the length of the file line.

UCHAR stbuf[81];    

UCHAR *stp; 

int mf_row;

...

...
/* file rows no more than 80 char. 
*/
mf_row = 5 
/* Get contents of file row
*/
mf_rowtxt(stbuf, mf_row, mfp);
/* Change file row 5 to uppercase
*/
st_toupper(stbuf);
/* Change buffer contents to uppercase
*/
mf_rowrpl(stbuf, mf_row, mfp);

...  

...  
/* Replace file row with buffer
*/


Home Contents Previous Next