Simple file manipulation

Sam Hu samhudotsamhu at gmail.com
Wed May 20 01:26:54 PDT 2009


I looked up in D2  in std.stdio,std.file,std.cstream and std.stream and try to find a very simple method which can read from a file once a  value other than once an entire row.I just can not find it maybe this idea is wrong.Say how to simply read & write key/value pairs to and from a file like this format:

//file "data.dat"
Tommy M 22

where the keys are name,gender and age while the values are Tommy,M ,22.

I found there is methods that can read from a file once an entire row.But is there a simple method which can read once a value?In C++ one can do like this:

#include <iosteam>
#include <fstream>
using namespace std;
ifstream inData;
inData.open("data.dat");
inData>>name;
inData>>gender;
inData>>age;

cout<<"Info:"<<endl
       <<"Name:"<<name<<endl
       <<"Gender:"<<gender<<endl
       <<"Age:"<<age<<endl;





More information about the Digitalmars-d-learn mailing list