   illogical problem
  This is my secound attempt to make a graphical tic tac toe and somehow making this game in graphic always causes bugs and problems.I use a char for the board like this:char gameboard[9] = {'0', '0', '0', '0', '0', '0', '0', '0', '0'};Where 0 doesn't show anything, X shows an x and O shows an o in form of an image. I'm sure there are many problems I haven't seen yet because i've been so busy to fix the following problem, but here is some of the event code: if (event.button.button == SDL_BUTTON_LEFT) {mousex = event.button.x;mousey = event.button.y; if (turn == player) {    int currentx;    int currenty;    int element=0;for (int i=0;i<3;i++) {   for (int a=0;a<3;a++) {  currenty = 72+(i*1)+(i*81);  currentx = 50+(a*1)+(a*88); if ((mousex>=currentx && mousex<=currentx+88) && (mousey>=currenty && mousey<=currenty+81)) {  if (gameboard[element] == '0') {gameboard[element] = player;turn = computer;break; }  }element++;   }    }}If the player clicks in any of the boxes while the box is empty, then it will add the players piece into that box. I made sure it worked by adding a cerr into the loop and clicked on every box, so it's not like the coordinates are wrong or something. It just won't add the pieces into the gameboard. I tried to set a random element in the game loop like this: gameboard[0] = player;then it worked..I can post more code if you want to..   
  I'm not too sure of your problem, but I'd recommend using a multi-dimensional array :char gameboard[3][3];Also I'd use integers instead of chars, but thats just a personal preferance.   ;  Your array is only 9 elements big so the code would be struct board[ 8 ]   ;  The only cause of your problem that I can think of (I'm only a noob though) is that you need to pass the gameboard into the function as a pointer or a reference.   ;  There are no compilation errors in this program and the gameboard array is global so I don't need any references or pointers.Quote:Your array is only 9 elements big so the code would be struct board[ 8 ] That's wrong, if I set 8 in the initialization of the array, compilation error will occur, only when you refer to the array it's 8 because the first element is 0.   ;  More code would helpWhat exactly is that code meant to be doing???   ;  The code above I posted is some of the code in the event loop. If it's the players turn, it will check where the player is clicking and if the box the player is clicking in is empty, the program will put a piece at that slot, that's all.The show function which shows the pieces looks like this:void showboard() {    int counter=0;for (int i=0;i<3;i++) {   for (int a=0;a<3;a++) {  if (gameboard[counter] == 'O') BlitSurface(50+(a*1)+(a*88), 72+(i*1)+(i*81), bricks, &brick[0]);  else if (gameboard[counter] == 'X') BlitSurface(50+(a*1)+(a*88), 72+(i*1)+(i*81), bricks, &brick[1]);    counter++;   }    }}That function is correct though, because i've tried to init the array with values like 'O' and 'X' and they were shown correctly.Edit:I found out what the problem is now, I removed a certain function in the game loop and it worked to put pieces.   ;  btw, that "break" statement in your first code sample will only exit 1 of the 2 loops.   ;  Yeah I know, I thought it would only exit the if statement though. The lines i=3 and a=3 were there before so it didn't continue the loop, I removed them though.   ;  Why aren't you using a multidimensionarray? (gameboard[3][3])Can you post the errors too please [smile]?-Stenny   