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.

Recommended Answers

All 4 Replies

How about using grid[ 0 ] = 'o';

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.

i have no idea
i hope sombody will help

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]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.