So im trying to make an empty array fill with the numbers printed in the serial monitor. I have a 4x4 keypad sending numbers into the serial monitor and i want to figure out how to make the numbers go into an empty array i have.
String passwrd[4] = {"0", "6", "4", "9"};
String passwrd2[4] = {};
Code^^^^ above is the 2 arrays i have, im gonna figure out how to check if they're the same, but thats a different can of worms
im very new to coding so lmk if its bad or not
PaulRB
October 31, 2024, 12:56pm
2
mbbadcoder:
lmk if its bad or not
It's bad.
Try reading the forum guide in the sticky post.
I don't think that the use of (an array of) String (capital S) makes sense.
char passwrd[4] = {'0', '6', '4', '9'};
char passwrd2[4];
if(memcmp(passwrd, passwrd2, sizeof(passwrd))
{
no match
}
Or
// the array has space for the terminating nul character
char passwrd[5] = "0649";
char passwrd2[5];
if(strcmp(passwrd, passwrd2))
{
no match
}
Not tested.
1 Like
Forget Strings. If you can understand this, you will be avoiding some extra work all over place:
char passwrd[4] = {3, 1, 4, 1};
char passwrd2[4] = {};
Learn about character arrays.
Which i didn't even use, unlike @sterretje . Either way.
a7
system
Closed
April 29, 2025, 1:04pm
5
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.