[Dev-C++] warning when deleting allocated mem
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Julio L. <ju2...@ya...> - 2001-12-19 02:09:03
|
I can't figure out why the compiler gives me a warning
about deleting the array in the following code:
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
ofstream fout;
ifstream fin;
int main()
{
char *pArray[2][2];
for(int i = 0; i < 2; i++)
for(int j = 0; j < 2; j++)
pArray[i][j] = new char [10];
strcpy(pArray[0][0],"1234567890");
strcpy(pArray[0][1],"1112131415");
strcpy(pArray[1][0],"1617181920");
strcpy(pArray[1][1],"2122232425");
cout << pArray << "\n\n";
fout.open("writing 2D array from stack.ini",
ios::out);
if(fout.good())
{
fout.write(pArray, sizeof pArray);
fout.close();
}
else
{
cout << "\n\nERROR, could not write data to
file...";
fout.close();
}
delete [] pArray;
system("PAUSE");
return 0;
}
Of course I can ignore the warning and it still runs
fine, but I still would like to know why it is giving
the warning...
=====
Julio
__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com
|