Hello All,
OK...
There are two words ("building" and "office"
scattered about a document. I must read this file into memory and in a loop, create a temp variable to hold the file contents so I can replace every instance of both "building" and "office" with a particular building or office [Sears Tower, etc.](merges).
The number of times to loop can be extremely great (mega loop) so it is very inefficient to do a replace every time. (there is no need to loop through the entire file every time just to locate these two words)
Instead, I am doing one scan of the file to record (into a variable) the location of every instance of both words (line # etc.)
Is there a way I can use these positions with pointers so that when inside the 'mega loop', I can go directly to the exact position of the word I aim to replace in the file, replace it, and proceed to the next instance and so on. (maybe seekg()?)
I know this would consume much less processor time and energy than some 'loop-through-every-char-in-the-file-each-time-replace-function'.
I'm developing this app with coldfusion and have pretty limited C knowledge, but any and all cf functions I've used are much too taxing on the processor, hence the need for something better and the posting of this thread.
Thanks,
Marc
OK...
There are two words ("building" and "office"
The number of times to loop can be extremely great (mega loop) so it is very inefficient to do a replace every time. (there is no need to loop through the entire file every time just to locate these two words)
Instead, I am doing one scan of the file to record (into a variable) the location of every instance of both words (line # etc.)
Is there a way I can use these positions with pointers so that when inside the 'mega loop', I can go directly to the exact position of the word I aim to replace in the file, replace it, and proceed to the next instance and so on. (maybe seekg()?)
I know this would consume much less processor time and energy than some 'loop-through-every-char-in-the-file-each-time-replace-function'.
I'm developing this app with coldfusion and have pretty limited C knowledge, but any and all cf functions I've used are much too taxing on the processor, hence the need for something better and the posting of this thread.
Thanks,
Marc