{1...9} または X でマークされたファイルから入力を読み取ろうとしています。値を分離し、それらをベクトルに適切に格納する必要があります。私はそうするのを助けるために「sstringstream」を使用しています:
void myclass::Initialize(ifstream &file_name)
{
string input;
int value;
//Initialize the values in the matrix from the values given
//in the input file, replace x with a 0
for(int i = 0; i < 9; i++)
{
for(int j = 0; j < 9; j++)
{
//Read the input from the file and determine
//if the entry is an "int" or "x"
file_name >> input;
cout << input << endl;
istringstream(input);
if(input >> value) //PROBLEM HERE!!
{
Matrix[i][j] = value;
cout << "Debug: Check for values in matrix: " << Matrix[i][j] << endl;
}
else
Matrix[i][j] = 0;
}
}
cout << "The values in Matrix after initialization: " << endl;
Print_result();
}
問題はif文で発生し、「入力」に整数がある場合、if文を実行しません。なぜ機能しないのかわかりません。