Put into an array
I have a database which has quite a few entries which looks like this:
module 1¦version 1¦description 1¦command 1
module 2¦version 2¦description 2¦command 2
I used the ¦ character to split the different sections.
What I am unable to do is read from this database and take everything up until the first ¦ char and put that in an array. Then ignore the ¦ char and take everything up until the next ¦ char and put it into another array and so forth.
Any ideas how to do this or am I going about this in the wrong way?
A database or a file?
If it's a file, then you can read a line and tokenize it using strtok().
You could also use istream.get() to read one character at a time, and then just ignore the '|'.
The long way around the horn. :D
while((ch = ifstream_var.peek()) != EOF)
if(ch == '|')
take an action
Kay I'm real confused. I've never worked with reading something from a file before.
>I've never worked with reading something from a file before.
It's the same as reading from cin except you have to open the stream yourself.