Trying to create a list of strings that can be modified

Hello, I am writing some code that will function as a RFID door system. At the beginning of the program, I want to define the list/array/vector and give it 6 strings. These strings are the codes of the acceptable ID's that will allow the door to be unlocked. So in the program it scans the list, and also can add a new string to the list if a new ID card wants to be added.

I have had trouble using arrays, and I know that vectors can be much easier. However, I've found that arduino doesn't support vectors? Anyone have any experience with vectors? Or using a list of strings in the past?

Mistake removed
If you know you are making exactly 6 then you can make variables for each.

or

Read this: Arduino - Strings - Tutorialspoint
and this: Arduino - Multi-Dimensional Arrays - Tutorialspoint
Then, see if you can't put the two together.

1 Like

??????
https://www.cplusplus.com/reference/vector/vector/

1 Like

Sometimes I get my languages mixed up.
Thanks for pointing it out my mistake. I've edited my reply.

Regardless, vectors are growing structures and unnecessary here. Either a fixed number of slots or a 2d array (because the keys should be uniform size) are best here.

1 Like

?

It depends. All Arduinos except the 8-bit AVR boards support it. If you're stuck on AVR, you can still get third party ports of the standard library.

1 Like

Assuming the RFID identifier are a known length, let's say 12 characters, you would set aside as many entries as the most you need and use a 2D array:

// Make room for 20 ID's of 12 characters each:
char ValidIDs[20][13] =
// Initialize the first six
{
"ID One",
"ID Two",
"ID Three",
"ID Four",
"ID Five",
"ID Six"
};
// The remaining 14 will be all zeroes.  If the first byte of an entry is zero, the entry is available.
1 Like