I have a similar problem. I need to read and store information from a file such as:
in int count=7; //count
int float end = 7.5 ; //end
out float myout =0; //my out

I need to store type(e.g. in or out), variable type (e.g. int), variable name (e.g. count), and variable value (e.g. 7). The main problem is that the "=" sign could be joined to the code, as in the first example, or separated by spaces.

Can you please show me how can I do that?

fstream will skip white space for you -- you don't have to do a thing

ifstream in("filename");
string word;
int val1, val2;
while( in >> word >> val1 >> val2)
    // do something with these values
8 Years
Discussion Span
Last Post by aitrade
char direction[4]; // in or out
char type[8]; // such as int, char, etc
char name[25]; // variable name
char value[10];
char filler; // just ignore the = symbol

while( in >> direction >> type >> name >> filler >> value )
   // do something with this information


Edited by Ancient Dragon: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.