Question
This needs to be done in C language: #define _CRT_SECURE_NO_WARNINGS #define _CRTDBG_MAP_ALLOC // need this to get the line identification //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF); // in main, after
This needs to be done in C language:
#define _CRT_SECURE_NO_WARNINGS
#define
_CRTDBG_MAP_ALLOC
// need this to get the line identification
//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF); // in main, after local declarations
//NB must be in debug build
#include
#include
#include
typedef enum{FALSE = 0, TRUE} BOOL;
struct Frame{
char* frameName;
struct Frame* pNext;
};
typedef struct{
char* animationName;
struct Frame* frames;
}Animation;
// Forward declarations
void InitAnimation(Animation*);
void InsertFrame(Animation*);
void DeleteFrame(Animation*);
void EditFrame(Animation*);
void ReportAnimation(Animation*);
void CleanUp(Animation*);
int main(void)
{
char response;
BOOL RUNNING = TRUE;
Animation RG;
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
Ini
tAnimation(&RG);
while (RUNNING)
{
printf("MENU 1. Insert a Frame at the front 2. Delete last Frame 3. Edit a Frame 4. Report the Animation 5. Quit ");
scanf("%c", &response);
switch (response)
{
case '1':InsertFrame(&RG);break;
case '2':DeleteFrame(&RG);break;
case '3':EditFrame(&RG);break;
case '4':ReportAnimation(&RG);break;
case '5':RUNNING = FALSE;CleanUp(&RG);break;
default:printf("Please enter a valid option ");
}
}
return 0;
}
The Animation is a series of Frame objects held in a single linked list (forward list) in dynamic (heap) memory. This memory model will be adapted to a C++ template in a later assignment. When the application is running you can: add a new Frame to start of the Animation Frame list delete the last Frame in the list edit a selected Frame to change the frame name report the Animation to show the list of Frame details quit An example of the output of the running application is given at the end. Yours must work identically and produce identical output. Note the following: the file you submit must be named ass0.c, dynamic memory management is done with malloc) and free), there is never any excess dynamic memory allocated- only allocate exactly what is needed for each string entered by the user you can only use functions like strlen) and strcpy etc. from the standard C library to handle strings of null terminated char, when the application terminates it releases all dynamically allocated memory so it does not have a resource leak (or you lose 30%). See the Marking Sheet for how you can lose marks, but you will lose at least 60% if: 1. you change the supplied code in any way at all - no code added (except header includes) or removed, no macros, no defines, no statics and no additional global functions or variables, 2. it fails to build in Visual Studio 2017 3. It crashes in normal operation (such as reporting an empty list etc.), 4. it doesn't produce the example output. The Animation is a series of Frame objects held in a single linked list (forward list) in dynamic (heap) memory. This memory model will be adapted to a C++ template in a later assignment. When the application is running you can: add a new Frame to start of the Animation Frame list delete the last Frame in the list edit a selected Frame to change the frame name report the Animation to show the list of Frame details quit An example of the output of the running application is given at the end. Yours must work identically and produce identical output. Note the following: the file you submit must be named ass0.c, dynamic memory management is done with malloc) and free), there is never any excess dynamic memory allocated- only allocate exactly what is needed for each string entered by the user you can only use functions like strlen) and strcpy etc. from the standard C library to handle strings of null terminated char, when the application terminates it releases all dynamically allocated memory so it does not have a resource leak (or you lose 30%). See the Marking Sheet for how you can lose marks, but you will lose at least 60% if: 1. you change the supplied code in any way at all - no code added (except header includes) or removed, no macros, no defines, no statics and no additional global functions or variables, 2. it fails to build in Visual Studio 2017 3. It crashes in normal operation (such as reporting an empty list etc.), 4. it doesn't produce the example outputStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started