CString Extension for numerical IO

I think it is fairly self explaining. I have added calls to put and get numerical entries
into the string class by Zafir Anjum. This, with the parsing routines already included, have
proven quite usefull at least to me.

The following extentions add numerical reading and writting to the CStringEx Class. The
default field length of 8 is used to support my application for Finite Element Card Immage
format of 10 fields of 8. Change as you desire. The original code is actually from the late
70’s and was in fortran. This is why some of the structure has evolved to the form that it
is now in.

The primary calls added are Put and Get functions for the major numerical types of int,
long, float and double. i.e. PutFloat() and GetFloat().

The core of two added functions PutFloatS and PutDoubleS were supplied by “Pierre Caussin
and Jean-Paul Retru”, Thanks. The change in these routines is the length specified is the
accuracy rather than the total length of the string.

One function you may wish to remove depending on your desires is the call to “Accuracy”.
This function sets the digits past 8 or 16 to zeros rather than the random numbers that
are default.

Primary added functions are

int GetInt();
long GetLong();
float GetFloat();
double GetDouble();
void PutInt(int i, int len=8);
void PutLong(long i, int len=8);
void PutFloat(float f, int len=8);
void PutDouble(double f, int len=8);
void PutFloatS(float f, int len=8);
void PutDoubleS(double f, int len=8);

Down load source and demo (VC6) – 27 KB

Updated on: April 14, 1999.

More by Author

Must Read