Hi, I have this problem. I want to initialize too the contents of the array made by the user. When I use delete [] array; it errors. How can I delete the contents in my array? :( * btw I used structure in my datas.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
void irec(){
char choice;
cout << "WARNING: Do you want to clear all data? (Y/N) ---> ";
cin >> choice;
if (choice == 'Y' || choice == 'y')
{
delete [] record;
ofstream("c:delete.txt", ios_base::trunc);
cout << "Data Deleted!";
system("pause>0");
}
else
cout << "**** Back to Menu ****";
system("pause>0");
You've shown us nothing about what record is, and how it's defined. Nor have you told us anything about the error you're getting. How do you expect us to know why the delete statement isn't working, if you withhold information from us? Why would you even bother seeking help from us, if you're not prepared to actually tell us anything that would help us solve the problem?
My guess would be that you're trying to delete something you didn't allocate in the first place.