Dealing with arrays, is there a tidy way?

Hi, I’m wondering if there is a cleaner way of achieving this (actual array is up to 128 chars) I am using this type of code to set triggers to pull data as it comes in over serial.

if(array[0] == ‘F’ && array[1] == ‘I’ && array[2] == ‘R’ && array[3] == ‘S’ && array[4] == ‘T’ && array[5] == ‘I’ && array[6] == ‘D’)

Is there a way to write it that would be more like;

If(array[0 to 6] == “FIRSTID”) ?

I saw something somewhere but can’t find it now.

Other option I guess would be to do math on it, define UIDs for each phrase?

Hoping there’s a simpler way?
I know nothing, have tried searching but probably don’t know the right words for the question.

Thanks!

Try strncmp().

Thank you!

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