Arrays, Structs, Union Flashcards
For an array initialised as int val[5]
What is the type and value of the reference:
val
Type: int *
Value: x
For an array initialised as int val[5]
What is the type and value of the reference:
val +1
Type: int *
Value: x + 4
For an array initialised as int val[5]
What is the type and value of the reference:
&val[2]
Type: int *
Value: x + 8
For an array initialised as int val[5]
What is the type and value of the reference:
*(val+1)
Type: int
Value: value of element in val[1]
For an array initialised as int val[5]
What is the type and value of the reference:
val + i
Type: int *
Value: x + 4*i
Array size of multidimensional arrays
R * C * k bytes
(where R is rows and C is columns)
What is the starting address of of A[i]
A + i * (C * K)
Difference between struct and Unions
In struct, each member is given a separate memory. While all members of union use the same memory location and so it can handle only one number at a time
Solving alignments problems
Remember what the lowest address must be divisible by what
How to reduce memory space of structs
Rearrange the elements by putting large data types first
How is the memory allocated for union
According to the largest element