c++ - read file 1 line at a time with variable amount of data on each line -


i have question on how read data input .dat file using isstream used chord implementation have inputs of various lengths , type. example of input shown below:

addc 2 #ignore msg
addc 3 #ignore msg
addc 9 #ignore msg
print 9
insert 2 data0
insert 9 data1
insert 3 data2

i capture each input line line, ignoring msg behind # key.

what i've done till yet follows:

if (myfile.is_open())  {     while (getline(myfile, line))      {         string command;         string id;         string input;         unsigned int hashkey = 0;          istringstream iss(line);         getline(iss, command, ' ');         getline(iss, number, ' ');         getline(iss, message, '#');           //other codes      }  } 

however, when read in file, seems somehow reads in more required @ times. example,

//first few commands till insert 0 fine
command = insert number = 2 input = data0
inserting data0 at: 2
command = insert number = 9 input = data1
command = insert number = 3 input = data2
//program stops here due fault in reading believe


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -