Its not possible to turn-off certain fields inside the struct at run-time. You can however have a pointer that points to a dynamically allocated array of doubles that can represent multiple fields. For example:
#include <stdio.h>
#include <stdlib.h>
struct stats
{
size_t number_of_doubles;
double* data;
};
void make_stats(struct stats* pStats)
{
pStats->number_of_doubles = 3;
pStats->data = (double*) malloc(pStats->number_of_doubles * sizeof(double));
}
void delete_stats(struct stats* pStats)
{
free(pStats->data);
}
int main()
{
struct stats foo;
make_stats(&foo);
foo.data[0] = 3.0;
foo.data[1] = 5.0;
foo.data[2] = 7.0;
delete_stats(&foo);
return 0;
}