I am attempting to build a Tic Tac Toe game in C++, however, I am very beginner in C++ but can code reasonably confidently in Python. This is my code so far:
#include <iostream>
using namespace std;
char matrix[3][3] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
void Draw()
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
cout << matrix[i][j] << " ";
}
cout << endl;
}
}
int main()
{
Draw();
return 0;
}
There is a problem when the programme gets to the 4th item in the list at line 3. E0146 - too many initializer values C2078 - too many initializers As such, the programme obviously won't run. Any help would be greatly appreciated as I have googled around and not been able to find an answer. Thanks
Have tried: char *matrix[3][3] etc: matrix[3][3] etc:
Okay, so I didn't know that there was a difference between " " and ' '. This has solved the problem in case anyone else runs into something like this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.