Time for some tough love here. There are a lot of problems - almost every line of code. The error basically says that you're getting a premature false positive from win.
Let's look at the if statement. It checks for 1 in the first or upper left tile, which is correct. Next, it looks for (d*d)-1
in the lower right. If all the tiles contained a number in sequence, that tile would contain d*d. BUT, that's a moot point, since the lower right tile is supposed to be blank, meaning that it is supposed to contain 0.
Then there's the for loop statements. for(int i = 0; i < (d - 1); i++)
This will cause i (and similarly, j) to stop after executing the loop with i == d - 2. You should understand why this is a problem.
Next, you're reassigning the contents of endgrid to every tile as you loop through them (sort of - see below). The won() function should not change any of the contents of the board array. It should only look at them.
Next is endgrid itself. It's set at (d*d)-1
to start and is incremented from there. Why? If you're using it to check values, it should start at 1.
Finally, I said "sort of" earlier. The next line is a return true statement. Since it is an unconditional return, it's going to terminate the won() function the first time it is hit, so only the first tile will be processed. If the for loops ever execute, you'll get a false positive from won.
BUT then again, the only way that the return true will ever execute, and also the only way that a win will be reported, is if the first or upper left tile is 1 and the lower right tile is (d*d)-1, or, for example, if d==3, then the lower right tile would have to be 8. You can test this with your code by moving the tiles to that position. (The order of the rest of the tiles wouldn't matter.)
You have a lot of work to do here. Depending on what changes you make, it may or may not work, or have additional problems. Once you rework it, if you still can't get it working, please post a new question with new code and details, rather than changing this one.
You should also try running the code with the debugger (debug50), stepping through the code and monitoring the contents of your vars, including the board array. Make sure that each line of code is doing what it is supposed to do.
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)