所以我有我的代碼如下。我正在鑲嵌矩陣/或pgm圖像。通過鑲板我的意思是在一定數量的列和行中重複自己。它看起來像是其中一個窗戶,窗玻璃全部將每個玻璃部分分開。向量向量的段錯誤
一個例子:http://1.bp.blogspot.com/_OLskT-GO5VE/TGqgrSX_o_I/AAAAAAAAA-4/vcCdn6hA3fI/s320/2007_12_warhol_cambell_soup.jpg這是湯罐的一個4×8矩陣(其本身是像素的一個巨大的矩陣
相信段故障是否與索引= K某處發生涉及,但我不能。發現任何錯誤,我調整大小的矩陣,這不應該是它
編輯:。固定例如
void panel(vector <VecofInts> &p, int inputRow, int inputColumn)
{
int i, j, v = 1, g = 1, k = 0, row, col;
row = p.size();//obtaining the original rows
col = p[0].size();//obtaining the original columns
p.resize((r * row)); //sets up the new matrix so I can add new elements.
/* This is my first test loop for the columns; I know I can create a single loop
for rows and columns but this will help me find problems more easily */
while(v < c){
...
}
/* this is the loop I'm having trouble with */
v=1;
while(v < c){
k = row;
while(g < r){
for(i = 0; i < row; i++){
k = k + i;
for(j = 0; j < col; j++){
p[k].push_back(p[i][j]);
}
}
g++;
k++; //this allows the g<r loop to continue and k not repeat itself
//in the first i loop again.
}
v++;
}
}
嘗試用標誌-g編譯它,並用如GDB調試器中運行,這給yoiu的代碼,該段錯誤發生的確切LNE。請參閱http://www.unknownroad.com/rtfm/gdbtut/gdbsegfault.html – tgmath
其中定義了變量「c」? –
我必須爲調試器做一些工作。我會沿途更新 – TrickyNicky