开发者

filing in c language [duplicate]

开发者 https://www.devze.com 2023-02-12 09:40 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Replacing a word in a file, using C
This question already has answers here: Closed 11 years ago.

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
0

精彩评论

暂无评论...
验证码 换一张
取 消