Docstoc
EXCLUSIVE OFFER FOR DOCSTOC USERS
Try the all-new QuickBooks Online for FREE.  No credit card required.

comparison

Document Sample
comparison Powered By Docstoc
					                                          Comparison of Data Types

Array                Structure                Array of Structure      Pointer to int      Pointer to structure

int array[Size]      typedef struct {         str_t arrstr[Size]      int *ptr            str_t *ptrstr
                       int f1, f2;
                     } str_t;                                         ptr = &i            ptrstr = &str

                     str_t str;


array[0] = 10        str.f1 = 10              arrstr[0].f1 = 10       *ptr = 10           (*ptrstr).f1 = 10
                     str.f2 = 20              arrstr[0].f2 = 10                           ptrstr–>f2 = 20


fun1(array)          fun2(str)                fun3(arrstr)            fun4(ptr)           fun5(ptrstr)
                                                                      fun4(&i)            fun5(&str)


void fun1(int a[])   void fun2(str_t s)       void fun3(str_t as[])   void fun4(int *p)   void fun5(str_t *ps)


a[0] = 10            s.f1 = 10                as[0].f1 = 10           *p = 10             ps–>f1 = 10

affects array        affects copy             affects arrstr          affects i           affects str

				
DOCUMENT INFO
Categories:
Tags:
Stats:
views:12
posted:7/31/2012
language:
pages:1