Good afternoon. I spent the whole afternoon going around revising my code since I have been using the DEV C ++ and I have compiled a matrix whose declaration had variables, however, I knew that it could not be and when I passed it to other compilers like the one in Visual Studio jumps an error.
After reading documentation of how to create dynamic matrices, I no longer remembered, and with the purpose of having the code run in any compiler, I have implemented what I have read in my code but I can not make the first operations in the first one. step and I do not know what is happening (once solved this would be an iteration of the same thing)
I leave the code here in case you can lend me a hand but first of all I explain in summary form because I want to use the dynamic matrices. Depending on some input data. This program will generate an output matrix always in the same way a huge number of rows (can be from 100 to 10,000 for example, from that number would be a bit exaggerated but it would not be unreasonable to obtain calculations with 30,000, 50,000 ... ptos why I need the dynamic calculation) and only three columns (which coincides with the typical canonical base x, yz)
From "dimensions" is when I start to prepare the dynamic matrix or in the line of this comment // Creating the pointers to create the matrices.
I have also read about the vector library but I do not know how to use C ++ and I have also read that it is one-dimensional. I know that with pointers you can do what I want because I have done it for years but I do not remember. Greetings and thanks.
EDIT WITH A MORE SIMPLE AND ENTENDABLE PROGRAM FOR ANYONE WHO CAN HAVE THIS DOUBT IN THE FUTURE:
#include "iostream"
#include "cstdlib"
using namespace std;
int main()
{
int i;
int a = 4;
int crea1=4;
double aux1[3] = { 1,5,7 };
double **p1;
p1 = new double *[a]; //Numeros de filas
**for (i = 0; i < 3; i++)** **Aqui es donde esta el error**
{
p1[i] = new double[3]; //Numero de columnas
}
for (i = 0; i<a; i++)
{
p1[i][0] = aux1[0];
p1[i][1] = aux1[1];
p1[i][2] = aux1[2];
}
delete[] p1;
cin.get();
return(0);
}