Arrays Flashcards

1
Q

Two ways to declare an array

A

int someInts[3];

int someInts[] = {2,3,4};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Where is someInts[2] located in memory?

A

&someInts[2] = {address of someInts} + (sizeof(int) *i)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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!
How well did you know this?
1
Not at all
2
3
4
5
Perfectly