Basics Flashcards

1
Q

On windows the compiler creates obj files, on linux the compiler creates o files, what is the part that puts the executable together?

A

The linker will create the executable

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

How can I check the size of a datatype or array etc?

A

sizeof operator

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

Whats the difference between a signed int and an unsigned int

A

A signed integer is a 32-bit datum that encodes an integer in the range [-2147483648 to 2147483647]. An unsigned integer is a 32-bit datum that encodes a nonnegative integer in the range [0 to 4294967295]. The signed integer is represented in twos complement notation.

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

Given that the first array element is accessible at index 0, what is the index for the last element?

A

-1

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

Vectors are a better way to deal with arrays in C++, they support lots of inbuilt methods such as size, push_back etc. They are also resizable. How can I store and get a value at index 0?

A

theVectorName.at(0) = 1;

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

How can I perform an explicit type cast?

A

static_cast(number)

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

Which library can help with testing and converting characters?

A

include

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

What is a library that can be used to work with C style strings?

A

include

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

How can I assign a value to an unassigned c style string:

char name[8];

A

strcpy(name, “Frank);

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

How can I get the length of a C string?

A

strlen(str)

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

How can I compare a C style string?

A

strcmp(str, “Another”); // > 0

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

What lib can I use to convert C style strings to other types?

A

include

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

What is the type size_t used for?

A

size_t is the unsigned integer type of the result of sizeof , _Alignof (since C11) and offsetof, depending on the data model.

size_t is commonly used for array indexing and loop counting. Programs that use other types, such as unsigned int, for array indexing may fail on, e.g. 64-bit systems when the index exceeds UINT_MAX or if it relies on 32-bit modular arithmetic.

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

C type strings are static in size, are C++ strings static or dynamic?

A

Dynamic

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

How can I concatenate C++ strings?

A

string p = string1 + string2;

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