I have a text file and i want to replace a word from a specific location. For example want to replace 5th word from 12th line of file. How i can do that?

Recommended Answers

All 3 Replies

Read the file one word at a time, saving the words in another file except replace the 5th word (or whatever number it is) with the new word. You need two files, an input file and an output file.

Once you have read the target word and written the replacement into the output file, you can read/write the rest of the source file into the output file, in chunks, for efficiency's sake.

dear post example of record replace plz

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.