Hello,
How do I express the following instructions
into "C" code? Pls give example.
The instructions:
Use structure pointers
additionally hidden behind typedefs;which point
to structure types, that are not publicly defined.
Thank you,
Adock.
Printable View
Hello,
How do I express the following instructions
into "C" code? Pls give example.
The instructions:
Use structure pointers
additionally hidden behind typedefs;which point
to structure types, that are not publicly defined.
Thank you,
Adock.
DO YOUR OWN HOMEWORK
This site is for helping people with (specific) problems, not doing the homework for them. Try on your own first and if you get stuck, we might help you if you give the right question.
Code:struct datastruct
{
int data;
};
typedef struct datastruct datastruct_s;
typedef struct datastruct *pdatastruct_s;
/* A pointer to the struct */
pdatastruct datastruct_ptr;
/* Allocate memory */
datastruct_ptr = malloc (sizeof (datastruct_s));
/* For safety check if operation was succesfull */
if (datastruct_ptr == NULL)
return ERROR;
/* Using the member of the struct */
datastruct_ptr->data = 2;
/* Free memory when done */
free (datastruct_ptr);
This is very good. Thank you "The Homeworker".
You're a scholar, and a gentleperson.
Adock.