Hello,
I am a beginner in C++ and I am trying to implement of IOSTREAM for reading data in notepad. then I get a problem in displaying the data on the console .
the file ....
example.txt
1 2 3 4 5 6
//------------basic information------//
No_id : 1.1.0
Name : Rain
Age : 12
activity : sport
drink : water
by example.txt , I want to display in console screen as
1 2 3 4 5
1.1.0
Rain
12
sport
water
and make character of " //" and " ; " become line comment function , such as in c++ .
i hope someone want make documentation for me.
thanks you
If all your tokens are followed by " : " and continue till a line break then that part is easy. Just read line-by-line and parse data after " : ". If you want to ignore "comments" then check if the first character in the line is a comment delimiter for whole lines comments and I suppose you can also parse the extracted tokenized strings for end-of-line comments.
pseudo
1 2 3 4 5 6 7 8 9 10 11 12 13
open file
extract line
parse for comment ("//" or ";")
is it a comment?
yes -> deal with it or ignore line
no -> parse line as data
find delimiter (" : ")
found?
yes -> parse for comment
comment found?
yes -> extract data, ignore comment
no -> extract data to end of line
no -> error?