Basics Flashcards
On windows the compiler creates obj files, on linux the compiler creates o files, what is the part that puts the executable together?
The linker will create the executable
How can I check the size of a datatype or array etc?
sizeof operator
Whats the difference between a signed int and an unsigned int
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.
Given that the first array element is accessible at index 0, what is the index for the last element?
-1
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?
theVectorName.at(0) = 1;
How can I perform an explicit type cast?
static_cast(number)
Which library can help with testing and converting characters?
include
What is a library that can be used to work with C style strings?
include
How can I assign a value to an unassigned c style string:
char name[8];
strcpy(name, “Frank);
How can I get the length of a C string?
strlen(str)
How can I compare a C style string?
strcmp(str, “Another”); // > 0
What lib can I use to convert C style strings to other types?
include
What is the type size_t used for?
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.
C type strings are static in size, are C++ strings static or dynamic?
Dynamic
How can I concatenate C++ strings?
string p = string1 + string2;