My best/messiest code so far (work in progress)
etian (31)

So as no one knows, for school I've been working on a tic tac toe game and its pretty fun! I tried doing some coding now but I look through all the code and its completely fine but I guess my home wifi is too laggy. :/

You are viewing a single comment. View All
etian (31)

Maybe I should just take down this post :/

Highwayman (237)

@etian why? This is a wonderful repository of knowledge and learning all supported upon the basis of your wonderful code, why would you destroy such a beautiful thing? If you take it down, no one will see your game or all these posts or anything else. No one here is admonishing you or trying to insult you in any way. In fact I guarantee that we all enjoy helping you. I personally apologize myself if I in any way insulted you. This is a good post, please don’t take it down.

etian (31)

@Highwayman it was smth like this for myother post

void checkwin()
{
for (int g=0;g<3;g++)
test=a[spot];
spot2++;
test2=a[spot];
spot2++;
test3=a[spot]
spot2++;
if (spot2==3)
{
spot2=0;
}
if (test == 'X' && test2 == 'X' && test3 == 'X')
{
cout << "Game over!\nYou won."
}

Highwayman (237)

@etian well it looks like you forgot to put a comma between spot2 and test3 on line 6, so there’s that...
Um, hmm..
you are trying to make test be equal to an array of characters, but it is an int. If you are thinking about the fact that test is at least 4 bytes long and a[n] will be only three bytes long, then I suggest putting in an actual cast to int so that that is more clear, if not, then that isn’t great, and I wouldn’t encourage it anyways, just use a new array of chars.

It seems like that’s the big thing there, you are make test 1 , 2 and 3 be equal to the arrays instead of the characters.

So

You created your array (a) like so.

// I want an array of arrays
char a[][] = { { 'T' ,  'i',   'c' },
                { 'T' , 'a' , 'c' },
                { 'T' , 'o' , 'e' } };

And then you set test to the first array of a, instead of the first element of the first array. Like so.

test = a[0]; // so you basically are setting it to { 'T' , 'i' , 'c' }; , instead of 'T' .
etian (31)

@Highwayman well i just fixed that up really quick itwasnt exactly like that i fixed all the simple errors and thx i forgot about that