Hello guys, I'm trying to do a push_back but Code::Blocks sends me a weird error. I have debugged this code many many times but I can't identify the error.
The method LoadFromConsole has the line with the error.
=========ERROR====================
#0 77353541 ?? () (??:??)
#1 773532FF ?? () (??:??)
#2 773DCB60 ?? () (??:??)
#3 773887B6 ?? () (??:??)
#4 773532FF ?? () (??:??)
#5 76AF9B9C msvcrt!malloc() (C:\WINDOWS\SysWOW64\msvcrt.dll:??)
#6 00406244 __cxa_allocate_exception () (??:??)
#7 76B97C64 msvcrt!_iob() (C:\WINDOWS\SysWOW64\msvcrt.dll:??)
#8 00000024 ?? () (??:??)
#9 00000001 ?? () (??:??)
#10 00000024 ?? () (??:??)
#11 00000064 ?? () (??:??)
#12 0028FC1C ?? () (??:??)
====================;============
I will paste some of the classes. If you need more to help me, I will paste the rest of the code.
Thank you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
class Block{
int m_left;
int m_top;
int m_right;
int m_bottom;
public:
Block();
void set_values(int,int,int,int);
void loadFromFile(ifstream*f);
void loadFromConsole(int x,int y, int z, int w);
int getValue(int side);
void print();
};
void Block::set_values(int izq,int arriba,int der,int abajo){
m_top = arriba;
m_left = izq;
m_bottom = abajo;
m_right = der;
}
void Block::print(){
cout<<m_left<<" "<<m_top<<" "<<m_right<<" "<<m_bottom<<endl;
}
class Board{
uint64_t m_timer;
int m_step;
int m_width;
int m_height;
vector<Block> m_blocks;
bool solveState(State*state);
bool isValid(State*state);
bool isValidSide(State*state,int cell,int side,int cell1,int side1);
bool isValidSideImplementation(State*state,int cell,int side,int cell1,int side1);
void printState(State*state);
public:
Board();
void loadFromFile(ifstream*file);
void loadFromConsole(int FIL, int COL);
void solve();
};
void Board::loadFromConsole(int FIL,int COL ){
m_height = FIL;
m_width = COL;
srand(time(0));
matriz = new int*[COL];
for (int i = 0; i < FIL; i++){
matriz[i] = new int[COL];
}
matriz[0][0] = rand()%8+1;
matriz[0][1] = rand()%8+1;
matriz[0][2] = rand()%8+1;
matriz[0][3] = rand()%8+1;
//Se rellenan la columna principal
for (int i = 1; i < m_width; i++){
matriz[i][0] = rand()%8+1;
matriz[i][1] = matriz[i-1][2];
matriz[i][2] = rand()%8+1;
matriz[i][3] = rand()%8+1;
}
for (int j = 4; j < m_width*4; j+=4){
matriz[0][j] = matriz[0][j-1];
matriz[0][j+1] = rand()%8+1;
matriz[0][j+2] = rand()%8+1;
matriz[0][j+3] = rand()%8+1;
}
for (int i = 1; i < m_width; i++ ){
for (int j = 4; j < (m_width*4); j+=4){
matriz[i][j] = matriz[i][j-1];
matriz[i][j+1] = matriz[i-1][j+1];
matriz[i][j+2] = rand()%8+1;
matriz[i][j+3] = rand()%8+1;
}
}
for(int i=0;i<m_height;i++){
for(int j=0;j< (m_width*4);j+=4){
Block block;
block.set_values(matriz[i][j], matriz[i][j+1], matriz[i][j+2], matriz[i][j+3]);
block.print();
m_blocks.push_back(block);
}
}
}
|