Arrays Flashcards
1
Q
Two ways to declare an array
A
int someInts[3];
int someInts[] = {2,3,4};
2
Q
Can array be compared with ==?
A
Nope! Arrays are just pointers to the first element, so that’ll compare the addresses of the first elements
3
Q
Is size stored in an array? A vector?
A
No to an array, its only used to set aside memory when first allocated. Vectors do though!
4
Q
Where is someInts[2] located in memory?
A
&someInts[2] = {address of someInts} + (sizeof(int) *i)
5
Q
Row major order
A
they are stored row by row in memory, [0,0][0,1][0,2][1,0][1,1][1,2]
6
Q
Command line paramteters?
A
int main (int argc, char **argv)
- argc is the num of elements in argv
- argv[0] is the exectuable name, a.out
- they are c-style strings!