Reading text file to specific sign in each line
I need to read some words from a text file looks like below:
01 00000101 # reset
01 0f020001 # ADC power down
01 0f000001 # single channel
As you can see there is specific comment sign in most of lines, so I need to stop saving words at this moment and move to next line, is there any implemented function to do this ? Next I can store all words in QbyteArray or something similar as usual.
Can anyone help me?
Hi and welcome to devnet,
You can read the file line by line and check for the presence of the comment char then do what you want.
You can use a variety of Objects (QTextStream for example) even from standard (StringStream). Please look deeply at this types and some simple statements will work fine for you.
It would be so easy as a loop with a inner if (or flag).