Program not functioning correctly

So my program is meant to receive an input and then find that input at the earliest position in Pi, then simply tell the user which position it is. Unfortunately it's not working properly, as no matter what number I enter the position is always 0 (as if the WHILE loop isn't even there). Can anyone tell me where I've made my fatal mistake?

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
  #include <iostream>

using namespace std;

int main() 
{
    char Pi[] = "314159265358979323846264338327950288419716939937510582";
    char digit;
    cout << "Enter a digit and I'll find the first time it appears in Pi" << endl;
    cin >> digit;
    
    bool found = false;
    int count = 0;
    while (found = false) 
    {
        if (Pi[count] = digit) 
        {
            found = true;
            count++;
        }
        else 
        {
            count++;
        }
        
    }
    cout << "The number " << digit << " was found at position " << count << endl;
    cin >> digit;
            
    return 0;
}
I think your problem is here:
while (found = false)
should be:
while (found == false)
Thanks :) The while loop is definitely working now, I can tell because every number I enter is now at position 1. So I guess it's not looping, can you see any other problems there might be?
Yep there it is. It's actually the same problem:
if (Pi[count] = digit)
should be
if (Pi[count] == digit)
xD damn I should have used my own head for that. Thank you so much it's finally functional :D
No problem, sometimes you just need another set of eyes.
Topic archived. No new replies allowed.