Line 112: This is a function declaration, not a function call. Since it's a bool function, you probably want to do something different if the board is full (like exiting the loop).
Why are you dynamically allocating the board? The only reason to do that is if you were to ask the user the dimension of the board they want to play with. Keep it simple and keep the board as as a fixed array.
Also, why are you dynamically allocating number of rows and columns? There is absolutely no reason to do this even if you were to support a variable size board.
You don't delete the menory you allocate. This results in a memory leak.
Don't use dynamic memory if you don't have a good reason to do so.
I consulted this exercise with my friend, and he gave me advice like this. But I agree, it isnt't the simplest way. I tried to change that, but I just can't, program didn't work. How should I change it? I will be grateful, if You give me one tip.
You are an awesome guy. Honestly, nowadays human's kindness becomes dead, so I'm really surprised. I used this code and changed something, I will show You tomorrow, and have a little bit questions, and I hope that You will help me :) Thanks for all Your engagement. :)
I made two select_field2 function, using rand, it works, but not at all. The program is looping up at some point, I don't know why. also when I type a letter instead a number in "podaj wiersz: ", program loops.
That's my functions:
Line 11,27: You should call srand() only ONCE at the beginning of your program. Otherwise, you reset the RNG to return the same set of numbers each time rand() is called.
I don't see your code for check_field(). I'm assuming it's similar to validate_field(), but without the couts.
Line 44: If check_field() returns false, that while statement is going to loop forwver.
Did you intend a do/while loop here (lines 28-44)?
Yes, I'm going to do this. But when I type in "podaj wiersz: " (row) any letter, program crashed. How can I correct it? And could You explain me this: if (turn_number & 1) ??
By doing a bit-wise and of turn_number and 1, we are checking if the lower order bit is set. turn_number increments each time through the loop. As turn_number increments, the low order bit toggles from 0 to 1. By checking if the low order bit is set or not, we're determining whose turn it is. i.e. User plays on even number turns (bit is off). Computer plays on odd number turns (bit is on).
Lines 9-12, 14-19, etc: You only want to allow a point for 3 in a row, if the position played is one of the three. Consider ##____ and i play position 4-6. Counter will be three, but I don't have three in a row.
Line 11,18,27,38: What if the pattern is ##_#__ and I play the first blank? counter will be 4, but I made 3 in a row.
Line 12,19,28,39: You probably want to check for 6 in a row first.
Line 25: You're missing a [.
Line 27: Where is punkty defined? Do you mean points?
Did you even try to compile this? You have a number of syntax errors.