Searching through a data file to match user input PIN

I am am trying to write a program to prompt the user to enter a 4 digit pin. If the pin matches a pin on the pre-recorded data file it should say "Access Granted" if it does not match the user has two more tries. I do not know how to get the program to read through the file, I have so many errors. I am suppose to use a sequential search algorithm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
  #include <iostream>
#include <fstream>
using namespace std;

int seqsearch(int codes[], int target, int n);
int main()
{
    int pin(0);
    int codes[300];
    ifstream myfile;
    myfile.open ("SystemAccessCodes.txt");
    
    for(int i = 0;i<300;i++)
    {
        myfile>>codes[i];
    }
    
    cout << "=====ENTER YOUR CODE TO ACCESS INTO THE SYSTEM=====" << endl << endl;
    
    for(int Attempts(1); Attempts <= 3; ++Attempts)
    {
        cout << "Attempt 1/3 : Enter 4 digit code ";
        cin >> pin;
        cin >> pin;
        if(pin != codes[300]){
            if(Attempts < 3){
                cout << "Try Again.\n";
                Attempts ++;
            }
            
            else if(Attempts == 3){
                cout << "Terminal locked.\n";
            }
        }
        
        else
        {cout<<"Access Granted";}
    
    
    system("pause");
    return 0;
}

// The sequential search function
int seqsearch(int codes[], int target, int n)
{
    n = 301;
    for (int i=0; codes[i] != 33; i++)
    {
        if (codes[i] == target)
        {n = i;
            break;}
    }
    return n;
    
}}
woudl you mind posting your errors?
Topic archived. No new replies allowed.