Esp32 "expression must have pointer-to-object type"

I’m having difficulty understanding pointers. I’ve read a number of articles now explaining this type of error and I tried to implement various suggestions in this little section of code.

void AssignSensorReadingsToArray() {
  SensorReading[1][0] = 1;
  SensorReading[1][1] = Temperature;
  SensorReading[1][2] = Humidity;
  SensorReading[1][3] = RelayState;
  AddReadingToSensorData(1,Temperature, Humidity); // Only sensor-1 is implemented here, could  be more though
}
//#########################################################################################
void AddReadingToSensorData(float Temperature, float Humidity) {
  sensordatatype sensordata[NumOfSensors][SensorReadings];
  byte RxdFromID=1;
  byte ptr, p;
  ptr = SensorReadingPointer[RxdFromID];
  sensordata[RxdFromID][ptr].Temp = Temperature;
  sensordata[RxdFromID][ptr].Humi = Humidity;
  ptr++;
  if (ptr >= SensorReadings) {
    p = 0;
    do {
      sensordata[RxdFromID][p].Temp  = sensordata[RxdFromID][p + 1].Temp;
      sensordata[RxdFromID][p].Humi  = sensordata[RxdFromID][p + 1].Humi;
      p++;
    } while (p < SensorReadings);
    ptr = SensorReadings - 1;
    sensordata[RxdFromID][SensorReadings - 1].Temp = Temperature;
    sensordata[RxdFromID][SensorReadings - 1].Humi = Humidity;
  }
  SensorReadingPointer[RxdFromID] = ptr;
} 

I know it’s my lack of understanding but could somebody explain simply what I’m doing wrong?

Normally this line

sensordatatype sensordata[NumOfSensors][SensorReadings];

is declared in the start-up, but if I leave it there it says sensordata is undefined so I tried moving it inside the code.
I know this is just a tiny portion of code but hopefully it’s enough to show you the errors.

Thank you in advance for the your kind assistance.

The code is slightly incomplete. Where’s the definition of sensordatatype, SensorReadingPointer, NumOfSensors, SensorReadings ?

Well byte ptr isn’t really a pointer here in the C/C++ type sense, it’s a numerical index.

Thank you for coming to my aid once more these definitions are defined at the start of the module:

#include <Arduino.h>
#include "Sensors.h"
#include "Main.h"

#define NumOfSensors    2  

SHTC3 mySHTC3;

float  Temperature          = 0;          // Variable for the current temperature
float  Humidity             = 0;          // Variable for the current temperature
float  LastTemperature      = 0;          // Last temperature used for rogue reading detection
int Light= 0;
//float  TargetTemp           = 21;         // Default thermostat value for set temperature
String result;
    
void AddReadingToSensorData(byte RxdFromID, float Temperature, byte Humidity);
String       SensorReading[NumOfSensors][6]; // 254 Sensors max. and 6 Parameters per sensor T, H, Relay-state. Maximum LoRa adress range is 255 - 1 for Server so 0 - 253
sensordatatype sensordata[NumOfSensors][SensorReadings];
int SensorReadingPointer;

And the type for that is in

? How’s that defined?

Anyways the problem lies here

You are accessing SensorReadingPointer as if it were an array of bytes (you’ve declared ptr to be of type byte). But the variable is in reality an int. You cannot use a subscript (variable[subscript_index]) on an int variable. It must a pointer to a byte or an array of bytes (if the ptr type was initially correct).

I’m having troubles understanding what the function AddReadingToSensorData is supposed to do internally to the data structure and how SensorReadingPointer comes into play for that. Can you explain your thoughts about what the function is trying to do and how these variables are supposed to used?

This is the same smart sensor from the code I posted to gethub (now removed)
what I’m trying to do is change the web sever they previously used back to the standard inbuilt version.

    #include <Arduino.h>
    #include "WiFi.h"
    #include <ESPmDNS.h> 
    #include <WebServer.h>
    #include "Main.h"

    extern WebServer server;
    extern WiFiClient client;

I was trying to rewrite it using the inbuilt WebServer
not ESP Async WebServer as it still frequently crashes with the watchdog timeout error on the server.
but to be honest I don’t understand what he was trying to achieve anyway, but is far too much to expect you to sort out a programme that has been butchered by me.

So what I will do is stop and just rewrite it to achieve a similar purpose but in a way that I can understand. Instead of just copying great chunks of code that I do not understand.

Sorry to have disturbed you again.
But thank you again for being so willing to help.