Hi guys,
I have a little troblue, you will see, I have the next code:
-------------------
//here all includes...
struct parts
{
int etiqueta;
float X, Y, Z, Q, T;
};
main ....
//I reserve dinamic memory for a bidimensional matrix...
parts **vert;
//la linea siguiente es la buena
vert = new parts*[n_cuadros];
//par es numero de cuadros
int par;
//entrada is a filestream
for (par=0;par<n_cuadros;par++)
{
vert[par] = new parts[n_particulas];
cout << "numero de cuadros: " << par+1 << "\n";
//i es el numero de particulas....
for (i=0; i<n_particulas; i++)
{
entrada >> vert[par].etiqueta;
entrada >> vert[par].X;
entrada >> vert[par].Y;
entrada >> vert[par].Z;
entrada >> vert[par].Q;
entrada >> vert[par].T;
}
for (int c=0;c<i; c++)
{
cout << vert[par][c].etiqueta<<" ";
cout << vert[par][c].X<<" ";
cout << vert[par][c].Y<<" ";
cout << vert[par][c].Z<<" ";
cout << vert[par][c].Q<<" ";
cout << vert[par][c].T<<" \n";
}
}
cout << "valor de par: " << par << "\n";
cout << " valor de la vert[0][0].etiqueta:[" << vert[0][0].etiqueta << "]\n";
cout << " valor de la vert[n_cuadros-1][5].etiqueta:[" << vert[n_cuadros-1][5].etiqueta << "]\n";
cout << "valor de n_cuadros :" << n_cuadros << "\n";
//liberar la memoria reservada:
for(int libera=0;libera<n_cuadros;libera++)
delete [] vert[libera];
delete vert;
------------------
well, this code works alone, but if I try to putting into a class (like a method, such as "read_file", for example), it brokes!! the "for" loop only works until 5 times, and then broke....
anybody can helpme?
I hope you can helpme please....
rick.
I have a little troblue, you will see, I have the next code:
-------------------
//here all includes...
struct parts
{
int etiqueta;
float X, Y, Z, Q, T;
};
main ....
//I reserve dinamic memory for a bidimensional matrix...
parts **vert;
//la linea siguiente es la buena
vert = new parts*[n_cuadros];
//par es numero de cuadros
int par;
//entrada is a filestream
for (par=0;par<n_cuadros;par++)
{
vert[par] = new parts[n_particulas];
cout << "numero de cuadros: " << par+1 << "\n";
//i es el numero de particulas....
for (i=0; i<n_particulas; i++)
{
entrada >> vert[par].etiqueta;
entrada >> vert[par].X;
entrada >> vert[par].Y;
entrada >> vert[par].Z;
entrada >> vert[par].Q;
entrada >> vert[par].T;
}
for (int c=0;c<i; c++)
{
cout << vert[par][c].etiqueta<<" ";
cout << vert[par][c].X<<" ";
cout << vert[par][c].Y<<" ";
cout << vert[par][c].Z<<" ";
cout << vert[par][c].Q<<" ";
cout << vert[par][c].T<<" \n";
}
}
cout << "valor de par: " << par << "\n";
cout << " valor de la vert[0][0].etiqueta:[" << vert[0][0].etiqueta << "]\n";
cout << " valor de la vert[n_cuadros-1][5].etiqueta:[" << vert[n_cuadros-1][5].etiqueta << "]\n";
cout << "valor de n_cuadros :" << n_cuadros << "\n";
//liberar la memoria reservada:
for(int libera=0;libera<n_cuadros;libera++)
delete [] vert[libera];
delete vert;
------------------
well, this code works alone, but if I try to putting into a class (like a method, such as "read_file", for example), it brokes!! the "for" loop only works until 5 times, and then broke....
anybody can helpme?
I hope you can helpme please....
rick.