我只是新来的论坛,我有我的c + +脚本的问题。 我需要输出一个字符串类型数组到输出txt文件。 我有一个数组,将其转换为字符并仍然存在问题。 它给了你前两行,但其余的是Ì或¤。 另一个问题是,我需要做一个endl,把这看起来是不可能的.put()函数。 好这里是我的方案的核心:C++ ofstream.put(char)给出奇怪的输出
ofstream ofile ("test2.txt", ios_base::trunc);
i=0;
j=1;
stringstream ss;
char oBoard[9][10];
//CHECK WHICH STARTER
if (ofile.is_open()){
if(board[0][0]=="b"){
ofile << "black" << endl;
}
else{
ofile << "white" << endl;
}
//START LOOPING FOR OUTPUT
while(j!=11){
i=0;
while(i!=10){
ss << board[i][j];
ss >> oBoard[i][j];
cout << oBoard[i][j] << endl;
ofile.put(oBoard[i][j]);
i++;
}
j++;
}
ofile.close();
}
'C++ script'? 'C++'是***不是***脚本语言。 – 2011-06-01 19:13:27
这显然不是C++。 – 2011-06-01 19:15:45