pin number error

I couldn't figure out what's wrong with this program. could any one help me take a look? Thank you!




#include <iostream>
#include <cstdlib>
#include <time.h>
#include <cstring>

void PIN (int Pin);
void random_numbers (int random_nums[]);
int isValid(int actual[], int entered[], int randum[]);// check the pin enter.


int main()
{
using namespace std;
// array to hold actual password
int Pin, actual_password[5],random_nums[10], relate_pin[5];


// Input the user's entry
cout <<"Please store your 5 digits PIN number in to program first: "<<endl;
cin >>actual_password[5];
system ("cls"); //clear the screen to hide the password for security concern

PIN (Pin);
random_numbers(random_nums);

cout << "Enter password corrsponding to the table: ";
for(int j =0; j < (sizeof (actual_password)/sizeof (actual_password[0]));j++)
{
cin >> relate_pin [j];
}

if ( isValid(actual_password, relate_pin, random_nums) )
cout << "Correct! You may now proceed"<<endl;
else
cout << "Error, invalid password entered"<<endl<<"Enter your password again."<<endl;



system ("pause");
return 0;
}


// using iostream:
void PIN(int pin)
{
using namespace std;
cout << "PIN number: ";
for ( int i = 0; i < 10; i++)
{
cout << i << " ";
}
cout << endl;
}
// using iostream:
void random_numbers(int random_number[]) //randomly generate numbers from 1-3 for each digit.
{
using namespace std;
srand ( time(NULL) );
for (int i=0; i<10;i++)
{
random_number[i]= (rand()%3)+1;

}
cout <<"Random number: ";


for (int i=0; i<10;i++)
cout <<random_number[i]<<" ";
cout<<endl<<endl;
}

int isValid(int actual[], int entered[], int randum[])
{
int index =0;
bool valid = true;
while (valid && (index < sizeof (actual)/sizeof (actual[0])))
{
int code = actual[index];
if (entered [index] != randum [code])
{
valid = false;
}
index ++;
}
return valid;
}
Topic archived. No new replies allowed.