Pointers and Arrays: How to correctly add values to an array using a function

Understanding that pointers are required for this, I have an array of values which ought to be filled recursively as the program loops. The data is coming from A0 which is switched through a multiplexer. Everything works as expected (averaging function, mux select function) however I cannot figure out how to correctly use pointers to update my array with a function on every loop.
Possibly the error lies in the function storeVals() and the use of switch statement, but more likely I have incorrectly implemented the pointer syntax to update the array via the function:

//*********************************************************         INCLUDES            **************//

#include <Defs.h>
#include <Mux.h>
#include <Type4067Mux.h>
#include <Series4000Mux.h>
#include <Type4051Mux.h>
#include <GenericMux.h>

//*********************************************************         CONSTANTS            **************//

// set size of averaging array
const int numReadings = 10;
// set total mux channels
const int ttlChannels = 8;
//*********************************************************         VARIABLES            **************//

//iterate through averaging array
int readings[numReadings];
int readIndex = 0;
int total = 0;
int average = 0;
int16_t data = 0;
int channel = 0;

//set data incoming pin || set channel switch pins
Type4067Mux mux(A0, INPUT, ANALOG, 8, 9, 10, 11);

//set the refresh interval
int period = 1000;

//setup milli start time
unsigned long time_now = 0;

//initiate the storage containers
int vals[ttlChannels] = {};

//*********************************************************         SET UP PINS            **************//

void setup()
  // initialize serial communication
  // initialize all the readings to 0:
  for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;
//*********************************************************         LOOP FUNCTION            **************//
void loop()
  channel += 1;
  if (channel >= ttlChannels)
    channel = 0;
  storeVals(channel, average, &vals[]);

  if ((unsigned long)(millis() - time_now) > period)
    time_now = millis();
    for (int i = 0; i < ttlChannels; i++)
      Serial.print("the reading on channel ");
      Serial.print(" is: ");
} //END loop

//*********************************************************         FUNCTIONS            **************//

///////////////////////////////////average readings function
int getAverage()
  // subtract the last reading:
  total = total - readings[readIndex];
  // read from the sensor:
  readings[readIndex] = data;
  // add the reading to the total:
  total = total + readings[readIndex];
  // advance to the next position in the array:
  readIndex = readIndex + 1;
  // if we're at the end of the array...
  if (readIndex >= numReadings)
    // ...wrap around to the beginning:
    readIndex = 0;
  // calculate the average:
  average = total / numReadings;
  // send it to the computer as ASCII digits
  return average;

//////////////////////////////////////multiplexer select function
int selectChannel(int channel)
  data = mux.read(channel);
  return data;

//////////////////////////////////////store values to variable function
int storeVals(int channel, int *average)
  switch (channel)
  case 1:
    vals[0] = *average;
  case 2:
    vals[1] = *average;
  case 3:
    vals[2] = *average;
  case 4:
    vals[3] = *average;
  case 5:
    vals[4] = *average;
  case 6:
    vals[5] = *average;
  case 7:
    vals[6] = *average;
  case 8:
    vals[7] = *average;
  return vals[];

For your original problem: You can use an index counter to see where in the loop to add the next value, then you simply use an index assignment operation to store the new value and then increment the index counter.

Extra: If you want to clean up your code a little, consider using FireTimer.h for easy implementation of software timers. It's installable via the Arduino IDE's Libraries Manager.

What are the 8 channels connected to? Are you trying to keep a running average of each separate channel, or an average of all the channels combined?

@power_broker: Thank you, good advice. I'll try it and report back.
@cattledog: 8 channels are, in testing phase, connected to a single potentiometer, but in deployment thermistors. Averaging values for each channel separately which will then be converted and displayed on 7 segment displays.

Averaging values for each channel separately

You current averaging routine does not separate the channels. You need an channel indexed array of averages.


@cattledog: you are right, thank you. Referring back to the original question my code plan was to 're-zero' the data variable once the average was successfully written to the vals array in preparation for incrementing channel. I'd forgotten this. i'll add to this new implementation and report back.