매트릭스를 읽으려고합니다. 나는 구글을 살펴 봤고 모든 사람들이 내가했던 것처럼 비슷한 것을 보았다. 그것은 컴파일하지만 첫 번째 위치에 대한 값을 소개하면 다음과 같이됩니다 : Segmentation Fault : 11. Linux와 Mac OSX에서이 코드를 시도했습니다. 그리고 나는 같은 오류를 얻는다.매트릭스 읽기 - 분할 오류
이 제 기능입니다 :
나는이 구조체가 :
struct Matri {
string idm; // name of vector
int rows;
int columns;
string id;
vector<vector<int> > matrix;
};
void readMatrix(Matri* m){
cout << "Introduce the name of the matrix" << endl;
cin >> m->idm;
cout << "Introduce number of rows: " << endl;
cin >> m->rows;
cout << "Introduce number of columns: " << endl;
cin >> m->columns;
m->matrix.resize(m->rows*m->columns);
cout << "Size: " << m->matrix.size() << endl;
for (int i = 1; i <= m->rows; i++){
for (int j = 1; j <= m->columns; j++){
cout << "Size of matrix: " << m->matrix.size() << endl;
cout << "Introduce values for position: " << i << ", " << j << endl;
cin >> m->matrix[i][j]; //THIS IS WHAT DOES NOT WORK. It says Segmentation Fault 11.
}
}
}
덕분에 많은 사전을!
감사합니다 당신이 대답을하지만 같은 문제도 그 변화가! – user3369375
@ user3369375 ... 다른 문제는 질문에 충분한 정보를 제공하지 않는다는 것입니다. –