Thursday, 12 September 2013

Struct and pointer sample

#include <stdio.h>

typedef struct Table Table;

struct Table {
        int Height;
        int  Width;
};

Table *  create_table(int height, int width)
{
    Table *mytable_ptr;

    Table my  = {height, width};

    mytable_ptr = &my;

    return mytable_ptr;

}



int main()
{
        Table  * my;
        my = create_table(10, 20);

       int height = my->Height;

       printf("h%d\n", height);
}

No comments:

Post a Comment