V
volk
Will this code leak memory? I hope I deleted the array correctly.
#include <iostream>
using namespace std;
int main()
{
//integers n and m represent the field
//n is rows and m is columns
int n = 5, m = 5;
int** field = new int*[n];
for(int i = 0; i < m; i++)
field = new int[m];
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
field[j] = '.';
//deleting array row by row
for(int i = 0; i < m; i++);
delete[] field;
//deleting last object
delete[] field;
return 0;
}
Thank you
#include <iostream>
using namespace std;
int main()
{
//integers n and m represent the field
//n is rows and m is columns
int n = 5, m = 5;
int** field = new int*[n];
for(int i = 0; i < m; i++)
field = new int[m];
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
field[j] = '.';
//deleting array row by row
for(int i = 0; i < m; i++);
delete[] field;
//deleting last object
delete[] field;
return 0;
}
Thank you