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?
#include <iostream>
usingnamespace 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;
}
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?