Possible Duplicate:
Replacing a word in a file, using C
i am doing filing in c language. i have created a txt file and write some data into it. but as my program progress i have to search some text and replace it with the other word but the problem i am facing is that suppose in my file i wrote
"i bought apple from the market"
if i replace apple with pineapples , as apple has 5 char and pineapple has 9 char it will write it as
"i bought pineapple m the market"
t开发者_JS百科hat it also has affect the words written after apple because of the different char length
i have use fseekpos function to find the pointer position
thanks
- take all data with io function
- store it in double pointer ( use two dimension )
- after seeing EOF, clear the used file, close it
- write some function to do your task and manipulate the data stored in two dimension
- open it again, but now to write the manipulated data in it
精彩评论