theukrainian wrote:111001 wrote:theukrainian wrote:По-моему не работает когда число приходится на границу строки в которой вы делаете replace.
Would you provide an example, please?
i could be wrong... but i think situation like the following:
"abcd.......123456abcd", where, say, '3' is symbol number MAXLINELENGTH (ie, if MAXLINELENGTH is 1000, then '3' is symbol number 1000, since fgets() will read at most MAXLINELENGTH - 1 (and null-terminate)...or stop at '\n' if it sees one).
There reason it seems to me that it does not work is because replace function is going to be called on "abcd....12", resulting in output of "abce...(12", and then it'll be called again on "3456.... " resulting in output of "(3456).....".
To fix this, replace() would need to keep state between invocations, but this would not be pretty.
I could be off by one, but what matters is the idea itself
.. am I missing something?
Спасибо за ответ.
Я, конечно, предполагал, что MAXLINELENGTH выбрана
достаточно большой, так что любая строка заведомо короче. Иначе все это лучше делать на бинарном потоке,
не разбивая на строки.