Hi , i have a text file in IFS which have some data. Now after reading i want to replace all occurance of xyz with abc and update the ifs file .Everything is working fine except updation . The problem is with pointer setting , everytime the data is appended in file rather than replacing ..I am using _C_IFS_fopen,_C_IFS_fgets,_C_IFS_fputs apis.
Please suugest how can i set the pointer to write date to exact position replacing the old one ...
Software/Hardware used:
As400
ASKED:
September 10, 2011 3:41 PM
UPDATED:
March 31, 2012 4:50 PM
As far as I know, you can’t use those APIs to update a streamfile as you want.
Usually, streamfiles aren’t updated. They are copied and the data is changed during the copy. You can use Unix APIs to cause streamfile updates, but you will find it much easier simply to read from the original file, change the data that you read and write it to a new file. After you finish, you can delete the original and rename the copy. (You might need to set owner and authority on the new file too.)
Tom
I routinely handle rtf (text) documents held in the IFS. Were I to do a replace I’d be reading the file, replacing as I go, and writing it back. Mostly courtesy of Scott Klement (thanks Scott) and his open source routines.