Here is my simplified version, using pointers instead of references. The code is almost identical. And it is still much easier to follow:
float BatVolts = 13.5;
float ACVolts = 236;
float WindSpeed = 3;
float PVCurrent = 20;
// number of items in an array
#define NUMITEMS(arg) ((unsigned int) (sizeof (arg) / sizeof (arg [0])))
// structure for name/value mapping
typedef struct
{
const char * name;
float * val;
} xVar;
xVar vals [] = {
{ "BatVolts", &BatVolts },
{ "ACVolts", &ACVolts },
{ "WindSpeed", &WindSpeed },
{ "PVCurrent", &PVCurrent },
};
void showValues ()
{
for (int i = 0; i < NUMITEMS (vals); i++)
{
Serial.print (vals [i].name);
Serial.print (" = ");
Serial.println (*vals [i].val);
}
} // end of showValues
void setup ()
{
Serial.begin (115200);
showValues ();
Serial.println ();
BatVolts = 12;
ACVolts = 240;
WindSpeed = 4;
PVCurrent = 18;
showValues ();
} // end of setup
void loop () {}