Creating Objects

Example
    char array[8];
    struct foo_t {
        char ch;
        short sh;
        long lg;
    } foo;

    int main() {
        char * ch_ptr;
        struct foo_t * foo_ptr; 

        /* Create a char object */
        ch_ptr = (char *)malloc(sizeof(char));        

	/* Create another char object */
	ch_ptr = (char *)malloc(sizeof(foo.ch));

        /* Create an array object of 4 chars */
        ch_ptr = (char *)malloc(sizeof(char) * 4);    

        /* Create an array object the same size as array */
        ch_ptr = (char *)malloc(sizeof(array)); 

        /* Create a struct foo object */
        foo_ptr = (struct foo_t *)malloc(sizeof(foo));

        /* Create another struct foo object */
        foo_ptr = (struct foo_t *)malloc(sizeof(struct foo_t));
    }
next slide