Automatic memory is freed when an object goes out of scope.
First, movies is a type, not an object. So this movies.title = "Harts War";
should be this
films->title = "Harts War";
But that is still wrong because you cannot assign C-style strings that way. Use strcpy or std::string for assignment.
What is the bigger picture? What do you want to do? (Don't solve the wrong problem with a perceived solution.)
-------------------------------------------------------------
THANK YOU. I am now able to create and delete a structure. As for the bigger picture, I had the functions working before I submitted my first post to this forum. I had perceived the deletion of a structure as a mere detail...until now. The reason follows and is based upon differences in the way in which one must code to use the structure after declaring it using a pointer reference.
When I created the structure using "movies films;", and referenced the data using "films.title" and "films.year", my file input/output (read/write to disk) functions worked well. When I create the structure using "movies *films = new movies;", and reference the contents using "films->title" and "films->year", I can no longer display the title. What is the difference between these two approaches, and why must I use two different means of referencing the variables that comprise the structure depending on how the structure is declared?
I am saving and reading structures from files using an iostream function and am referencing the structure to be saved using a char pointer as "(char*)(&films)". The problem seems to arise if I use the pointer means of declaring the structure ("movies *films = new movies;") when I read from the file and try to display "films->title" in a RichEdit text control using "RichEdit2->Text = films->title". I had this problem previously when I declared "title" to be an AnsiString, but worked through it and used char[10] to declare "title", StrCopy() to load data into "films.title", and "RichEdit2->Text = films.title" to display it.
(Just a note, in that the use of movies instead of films in the variable assignment in my prior post was not a conceptual error, I typed the wrong variable name in the post. (They sound similar, and I didn't have the code in front of me). I had worked through the StrCopy() problem last night when I first encountered it, but had forgotten how to handle it this morning when the error arose again after I had retyped a segment of code with the new declaration statement. I probably would have continued to struggle had the prior post not reminded me of the manner of solution of that problem.)
I am most certainly not trying to diminish the value of the assistance I have received here, and am both surprised by and grateful for the speed of the responses I have received.
I had hoped to create a general structure I/O function for my future use, but now seem to need to create two differently coded structure I/O functions to accomodate the pointer means of declaring the structure, particularly if I wish to comply with the current C++ ANSI standard in my coding efforts in terms of the means by which I declare a structure. Using the iostream method, a pointer to a location in memory, and the size of the data I need to store, doesn't seem to enable me to display the title using "RichEdit2->Text = films->title;". I had previously been able to load the title as part of the structure that was loaded using the iostream method, then used "RichEdit2->Text = films.title" to display the title when I declared the structure using "movies films;".
Once again, and most sincerely, thank you!