わかりました、これに関するすべての質問をチェックしましたが、まだわかりません。ループを使用して、文字列配列をファイルに書き込む必要があります。読み取りセクションは正常に動作していますが、これはデバッグ時に特定のものではありません。では、ここで問題です。
それは私に与えます:アクセス違反ですが、正確な行を与えることはできません。私は c++ を初めて使用し、例外処理があまり得意ではありません。EDIT: 変数と配列は上のセクションで宣言されていますが、私はそれらを与えます。
string bord[10][10];
string line;
int i=0,j=1;
ifstream ifile ("test.txt");
//readfile
if (ifile.is_open()){
getline (ifile,line);
bord[0][0].assign(line,0,1);
cout << "i=" << i << " j=" << j<< " inhoud - " << bord[0][0] << endl;
while (j!=11){
getline (ifile,line);
cout << line << endl;
i=0;
while (i!=10){
bord[i][j].assign(line,i,1);
cout << "i=" << i << " j=" << j<< " inhoud - " << bord[i][j] << endl;
i++;
}
j++;
}
ifile.close();
}
ofstream ofile ("test2.txt", ios_base::trunc);
//Write File
if (ofile.is_open()){
if(bord[0][0]=="z"){
ofile << "zwart";
}
else{
ofile << "wit";
}
//START LOOPING FOR OUTPUT
for(j=1; j<11; j++){
ofile << endl;
for(i=0; i<10; i++){
cout << "i=" << i << " j=" << j<< " inhoud - " << bord[i][j] << endl;
ofile << bord[i][j];
}
}
ofile.close();
}