passing pointer of multidimensional struct to a function/ class

Hi all,
I’m trying to pass a pointer of a multidimensional struct (Array of struct) to a function.

struct data{
	int t1;
	int t2;

data Data1[10];

void showAll(struct data *ptData)
for(int i = 0; i < 10; i++)
  Serial.println( *((ptData->t1)+i) ); 

My problem is, that I don’t know how to “index” the pointer on the struct array.
Do you maybee have a hint for me?
Thank you very much!

A single dimension array of structs is not a "multidimensional struct". Use:




Hi gfvalvo,
thank you very much! Your suggestion works in the shown example which I used to simplyfy my question.

I'm sorry, but my actuall project contains multiple files (.cpp and .h) which are also containing a class.

using ptData*.t1 seems to be one step ahead, but the compiler still gives me this error meassages:*
invalid use of incomplete type 'struct data'
in file included from class.h note forward declaration of struct data..
Do you have another hint for me?
Thank you very much!

Do you have another hint for me?

Impossible given the information provided.

Where do you actually declare the struct? The compiler is likely complaining because it does not know enough about the struct.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.