struct Case { char Name[100]; int CaseID; char CaseStatus[100]; };
The above piece of code defines data type "struct Case". This is to let the OS know that when we refer to data type "struct Case" in our program, we'd mean a structure which has the fields as defined in the structure-definition above.
char *dummyname = {"Jack"}; int dummyid = 123456; char *dummystatus = {"Open"}; struct Case *MyCase;


MyCase = (struct Case *)malloc(sizeof(struct Case));
This line calls the function MALLOC to allocate enough memory to hold a struct Case. Malloc returns a pointer to this newly allocated memory; this pointer is assigned to the variable MyCase.


strcpy(MyCase->Name, dummyname); MyCase->CaseID = dummyid; strcpy(MyCase->CaseStatus, dummystatus);


 
free(MyCase);
This de-allocates the memory previously allocated by MALLOC and returns it to the OS to be used by other processes.


Back to Index