parsing text file in C++ and read specific lines
Hi
My text file looks like Code:
<block event="1"> Code:
bool begin_tag = false; |
Quote:
What output do you want to produce or what processing are you trying to do? Quote:
Are blocks nested? Your example did not show blocks nested. If you want a non recursive function to process nested blocks, you probably want your variable begin_tag to be a count rather than a bool. It should hold the number of blocks that have started but not completed. If blocks can't nest then that number is just 0 or 1 depending on whether you are reading inside or outside a block. But if blocks can nest then it can go higher than 1. If you want to recursively process blocks that can nest, you want a function that can be called at the beginning or can be called right after reading a block even, then it reads up to either the end of the block or end of the file. If it sees a nested block, it calls itself to process that nested block. |
My text is like a xml ie each block starts with
Quote:
Quote:
thanks -a |
The same thing happens to me in person when someone says a sentence and mumbles just the most important words, so the meaning of the sentence is lost. If I ask them to say it more clearly, only the filler words are ever pronounced more clearly. The important words are always mumbled just the same the second time as they were the first.
Post #3 of this thread clarifies nothing that was unclear in post #1. What is insufficient about the code you showed in post #1? What do you want to do that this code cannot do? Quote:
In post #3, you replaced that with "each time". I still can't guess what that might mean in terms of something a program would do. |
I am sorry..I thought was clear what I want to do - From a file containing entries like
Code:
<block event="1"> Code:
This is the contents of block number 1 Code:
This is the contents of block number 2 Code:
<block event="1"> thanks -a |
All times are GMT -5. The time now is 03:26 PM. |