I’m just new to the forums and I am having problems with my c++ script.
I need to output an array of string type to an output txt file.
I have an array, converted it to chars and still problems.
It gives you the first 2 lines, but the rest is either Ì or ¤.
Another problem is the fact that I need to make an endl, put this seems to be impossible with the .put() function.
well here’s the core of my program:
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();
}
Well, what is the problem to use the
ofilein the loop with the same syntax, as before the loop?instead of