Corect use of pointer?

Hello, I'm having trouble understanding pointers and want to know if I'm on the right track.
I have an array of midi notes and wish to create a C major scale from that array. int notes[13] = { 60,61,62,63,64,65,66,67,68,69,70,71,72 }; Can I use an array of pointers like this int Cmajor = &notes[0,2,4,5,7,9,11,12]; Each value indexes a position within "notes[13]".
If this is correct then I want to check that with the serial monitor but I an completely confused how to write that now after looking at various sites. Here's an embarrassing mess that I have so far..

int notes[13] = { 60,61,62,63,64,65,66,67,68,69,70,71,72 };
int *Cmajor;
 
 Cmajor = &notes[0,2,4,5,7,9,11,12];

void setup() {
  Serial.begin(9600);
  Serial.println(Cmajor[0]);
}
void loop() {}

Obviously doesn't compile... Any help welcome :slight_smile:

int Cmajor = &notes[0,2,4,5,7,9,11,12];

What the Hell is that supposed to be?

Cmajor = &notes[0,2,4,5,7,9,11,12]; Even if it made sense, it isn't in a function.

If you want a single reference to individual element in the array:

int notes[13] = { 60,61,62,63,64,65,66,67,68,69,70,71,72 };
int &Cmajor = notes[1];

Ok so how I can I check that single element in the serial monitor?

goatboyrobbie:
Ok so how I can I check that single element in the serial monitor?

Serial.println(Cmajor);

Thank you. Can this Cmajor = notes[0,2,4,5,7,9,11,12]; be used to print the referenced elements of " notes[....etc? "

goatboyrobbie:
Thank you. Can this Cmajor = notes[0,2,4,5,7,9,11,12]; be used to print the referenced elements of " notes[....etc? "

No, that just not part of the language syntax

Ok so if I want to choose elements of int notes[13] = { 60,61,62,63,64,65,66,67,68,69,70,71,72 }; and use those elements to form a scale of usable notes, because I will eventually want to create many scales, would I use an array of pointers as such? int Cmajor[8] = {0,2,4,5,7,9,11,12};

That looks more like an array of indices

I know I have to be careful now but I think that is what I'm looking for! I want to index "notes..."

goatboyrobbie:
Ok so if I want to choose elements of

int notes[13] = { 60,61,62,63,64,65,66,67,68,69,70,71,72 };

and use those elements to form a scale of usable notes, because I will eventually want to create many scales, would I use an array of pointers as such?

int Cmajor[8] = {0,2,4,5,7,9,11,12};

If you want to have a subset of your original array, you can do:

int notes[13] = { 60,61,62,63,64,65,66,67,68,69,70,71,72 };

int *notesSubSet = &notes[2];

Then the first element of "notesSubSet" will be the third element of "notes"

And if I want to include multiple elements in that subset?

goatboyrobbie:
And if I want to include multiple elements in that subset?

That subset is a continuous array of your original set.
So subset[0] is notes[2]
subset[1] is notes[3]
subset[2] is notes[4]

Ok cool! Thanks Arduino_new!