0

I am making a tic tac toe game, and for the grid, I had originally made 9 variables to represent the grid's spaces, but instead, I would now like to use a single char array. I can make the array and print certain parts, but I can't change them.

For example: char grid[] = "xoxoxoxox"; But then if i want to change the first entry to also be a "o", how would I do that? I tried grid[0] = "o"; But it didn't work, it said invalid conversion from char to const char (possibly the other way around...)

Thanks everyone.

5
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by WaltP
0

Double quoted literals are used to define strings, while single quoted literals for characters. Since you are creating an array of characters, you need to enclose the O in single and not double quotes like Wolfy has already said.

0

i have no idea
i hope sombody will help

Two people already have -- Wolfie directly answering your question, SOS explaining something you need to understand. And here's a third:
TTT is played on a 3x3 grid, therefore you should consider using a 3x3 array (matrix), like char grid[3][3]

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.