Program Crash When I try to Find a Number in List

Everything in my code works except for the part when I try to find a number in the list. If I try to find a number that's not there when there's something in the list, the code works but it crashes and I'm not sure why. Please help! Thank you.

Here is my code:
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include<iostream>
#include<cstdlib>
#include<conio.h>

using namespace std;

struct Node
{
    Node *previous;
    int number;
    Node *next;
};

int main()
{
    Node *first = NULL;
    Node *last = NULL;
    Node *tempPrevious;
    Node *tempNext;
    Node *N;

    int inList;
    int option, temp;

    inList = 0;

    do
    {
        system("cls");
        cout << "Enter one of the following options: " << endl;
        cout << "\n\t1 - Display numbers in list ";
        cout << "\n\t2 - Add number to the front of the list ";
        cout << "\n\t3 - Add number to the end of the list ";
        cout << "\n\t4 - Find number in the list ";
        cout << "\n\t5 - Quit " << endl;
        cout << "\n\tEnter you option: " << flush;
        cin >> option;

        switch(option)
        {
            case 1:
                system("cls");
                if(inList == 0)
                {
                    cout << "List is empty. " << endl;
                }
                else
                {
                    cout << "List contains: " << endl;
                    N = first;
                    while(N -> next != NULL)
                    {
                        cout << N -> number << ", ";
                        N = N -> next;
                    }
                    cout << N -> number;
                    cout << " Null - End of List";
                }

                cout << "\nPress any key to continue. ";
                getch();
                break;

            case 2:
                system("cls");
                N = new Node;
                inList += 1;
                cout << "Enter number: " << flush;
                cin >> temp;
                N -> previous = NULL;
                N -> number = temp;
                N -> next = first;
                first = N;
                if(inList == 1)
                {
                    last = N;
                }
                if(inList > 1)
                {
                    N = N -> next;
                    N -> previous = first;
                }
                cout << "\nPress any key to continue. ";
                getch();
                break;

            case 3:
                system("cls");
                N = new Node;
                inList += 1;
                if(inList == 1)
                {
                    first = NULL;
                }
                cout << "Enter a Number: " << flush;
                cin >> temp;
                N -> previous = last;
                N -> number = temp;
                N -> next = NULL;
                last = N;
                if(first == NULL)
                {
                    first = N;
                    N -> previous = NULL;
                }
                else
                {
                    N = N -> previous;
                    N -> next = last;
                }
                cout << "\nPress any key to continue. ";
                getch();
                break;

            case 4:
                system("cls");

                if(inList == 0)
                {
                    cout << "List is empty. ";
                }
                else
                {
                    cout << "Enter number: " << flush;
                    cin >> temp;
                    N = first;

                    {
                        if(N -> number == temp)
                        {
                            cout << "\n" << temp << " is in the list. " << endl;
                            break;
                        }
                        else
                        {
                            tempPrevious = N -> previous;
                            tempNext = N -> next;
                            N = tempNext;
                        }
                        if(i = inList && N -> number != temp)
                        {
                            cout << "\n" << temp << " not in list." << endl;
                        }
                    }



                }
                cout << "\nPress any key to continue. ";
                getch();
                break;

            case 5:
                system("cls");
                cout << "Quitting... " << endl;
                exit(0);
                break;
        }

    }while(option != 5);
    return 0;
}


This is the part that doesn't work:

1
2
3
4
5

                       if(i = inList && N -> number != temp)
                        {
                            cout << "\n" << temp << " not in list." << endl;
                        }


Here is a photo with what happens when a number isn't on the list, it finds it but the exe crashes:
http://imgur.com/a/l0TYD
= is assignment operator and == is equality operator. It is easy to confuse these two. You should be using the == (equality) operator.
Topic archived. No new replies allowed.