Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to store an array.

Status
Not open for further replies.

caramelz

Junior Member level 2
Joined
Jul 19, 2012
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,464
guys i need some help. i wan to store an password inside the keypad so when correct password is typed in the keypad, the programme will jump to the next selection, if not it will loop back. help please
 

just predefine your password length and keep them storing in contiguous memory location in an array.
like suppose you have predefined password in char array pass[4]={'1','2','3','4'}.
then when you take input from user put it in other array let it be char user[length] and take the input in it.
then compare each element of both arrays i.e. use
Code:
for(i=0;i<pass_length;i++)
{if(pass[i]!=user[i])
flag=1;
break;
}
now after this loop check if flag is 0 if it is then password is correct.
 
Last edited:

i did a DO loop for 3 times, so th;e keypad only can key in 3 numbers. so do i have to come out with a StoreArray[3]={'1','2','3'};
Code:
if i name the input as keyPad

for(i=0;i<StoreArray_length;i++)
Code:
{if(StoreArray!=keyPad)
flag=1;
break;
Code:

is it like that ? sorry i'm a beginner in this. and btw the code u gave work for C++ right\?
 

first of all to maintaint clarity always post code in code tags(# sign given on top).
the code is right although i forgot to put } after break which i have corrected nowand it will work for both c and c++.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top