我试图在c中初始化一个tic-tac-toe板,但输出总是给我六进制值.有没有办法将它们转换为实际的字符串值?
#include <iostream> #include<string> using namespace std; int main() { string tab[5][5] = { "1","|","2","3","-","+","4","5","6","7","8","9" }; for(int i = 0; i <= 24; i++) { cout << tab[i] << endl; } }
解决方法
你将tab [i]的值发送到cout,所以你得到了内存地址.
您可能希望更深层次地嵌套项目,例如tab [i] [j].