Term
Where is memory from compile time (static memory) stored?
|
|
Definition
|
|
Term
Where is memory from runtime (dynamic memory) stored? |
|
Definition
|
|
Term
do changes to the parameters affect arguments in pass by value? |
|
Definition
|
|
Term
Do changes to parameters affect the arguments in Pass by Reference? |
|
Definition
|
|
Term
How do you declare a pass by reference variable in a parameter? |
|
Definition
use "&" between data type and variable name.
void HT(int&x) |
|
|
Term
|
Definition
|
|
Term
ways to initialize a static array |
|
Definition
int data[10];
int data[] = {1,2,4};
int data[10] = {1,2,4}; //assigns first three, rest are 0
int data[10] = {0}; //clears array |
|
|
Term
How to pass array data of size 10 into void function doubleA |
|
Definition
void doubleA(int[], int);
int main()
{
int data[10];
//ask user to enter 10 values
doubleA(data, 10);
return 0;
}
void doubleA(int d[], int size)
{
for (int i = 0; i < size; i++)
d[i] = d[i] * 2
} |
|
|
Term
how to copy string "name" into "name2" |
|
Definition
strcpy(name2, name);
//destination must be long enough |
|
|
Term
how to determine the length of string "name" and place into variable "var" (2 ways) |
|
Definition
int var = strlen(name);
int var = name.length(); |
|
|
Term
- how to compare the contents of string "arg1" with string "arg2"
- how are they compared
- what is returned if
- arg1 < arg2
- arg1 > arg2
- arg1 == arg2
|
|
Definition
- strcmp(arg1, arg2)
- compares each member of strings until 2 different values are reached
- returns:
|
|
|
Term
int data[5][6];
which is columns, which is rows |
|
Definition
|
|
Term
|
Definition
main()
{
int data[5][6];
foo data();
}
void foo(int d[][6])
{} |
|
|
Term
How many bytes are grouped to make an integer? |
|
Definition
|
|
Term
What does the Virtual Memory Manager (VMM) do?
What does it allow? |
|
Definition
swaps memory between RAM and hard drive.
Allows more space than thats available on RAM to be used in a program |
|
|
Term
What is stored inside of a pointer variable? |
|
Definition
|
|
Term
how do you declare an integer pointer "p"? |
|
Definition
|
|
Term
How do you initialize a 2-dimensional int array?
2-dimensional char array?
|
|
Definition
int data[4][3] = {{1,3,5}, {2,4,6}, {9,10,11}, {1,1,1}};
char names[5][4] = {"SMU", "TCU", "UTD", "UTA", "UN"}
// S M U ø
//null-terminated c-strings |
|
|
Term
how to display a the memory address of variable x |
|
Definition
|
|
Term
What does it mean to dereference a pointer? |
|
Definition
To go to the address that is held in that variable and change its contents |
|
|
Term
How to derefernce variable "p" and change it to 15? |
|
Definition
|
|
Term
if int y[10]; is a "constant pointer" to the memory address 2012, where does y+1 point? |
|
Definition
2016 (second element of the array) |
|
|
Term
what is another way of writing d[i]?
(subscript notation ↔ pointer offset deferenced) |
|
Definition
|
|
Term
char data[10] = "SMU";
cout << data;
//what will display? |
|
Definition
|
|
Term
words[10] = "SMU"
char*data = words;
cout << *data;
//what will display? |
|
Definition
|
|
Term
char data[10] = "SMU";
cout << data+1;
//what will display? |
|
Definition
|
|
Term
char names[5][7] = {"SMU", "TCU", "UTD", "UNT", "UTA"};
cout << names[3] + 1; //what will display?
|
|
Definition
|
|
Term
char names[5][7] = {"SMU", "TCU", "UTD", "UNT", "UTA"};
cout << *names; //what will display? |
|
Definition
|
|
Term
char names[5][7] = {"SMU", "TCU", "UTD", "UNT", "UTA"};
cout << *(names[4] + 2); //what will display? |
|
Definition
|
|
Term
char names[5][7] = {"SMU", "TCU", "UTD", "UNT", "UTA"};
cout << *(*(names + 2) + 1); //what will display? |
|
Definition
|
|
Term
char names[5][7] = {"SMU", "TCU", "UTD", "UNT", "UTA"};
cout << (*names + 1); //what will display? |
|
Definition
|
|
Term
declare and initialize a dynamic integer array of size m integers, "p" |
|
Definition
|
|
Term
- What is a memory leak?
- How do you avoid this?
|
|
Definition
- memory that is allocated but never deallocated
- free/deallocate any dynamically allocated memory
|
|
|
Term
- If you have allocated an array pointed to by x, how do you free this memory?
- For a non-array?
|
|
Definition
|
|
Term
What is wrong with the following?
int*p;
cout << *p; |
|
Definition
uninitialized pointer, you may get a segmentation fault |
|
|
Term
How to make an array of char pointers of length 5 called "temp" |
|
Definition
char**temp = new char*[5] |
|
|
Term
what do you need to #include for file IO? |
|
Definition
|
|
Term
- input from a file
- output to a file
|
|
Definition
|
|
Term
how to reset a file object for looping |
|
Definition
|
|
Term
how to do end of file marker for "fin" |
|
Definition
|
|
Term
how to read an entire line to fill char data[50] |
|
Definition
getline(destination array variable name, number of spaces);
i.e.
char data[50];
fin.getline(data, 50); |
|
|
Term
How to create a file called output.txt
ofstream fout; |
|
Definition
|
|
Term
how to ignore a line in a file for "fin" |
|
Definition
fin.ignore(amount of space, another amount of space);
i.e. fin.ignore(80, '\n'); |
|
|
Term
- Between pass by reference and pass by value, which is faster?
- Why?
|
|
Definition
- Pass by reference
- No copy is made
|
|
|
Term
What does "using namespace std" allow user access to? |
|
Definition
components of the c++ standard library |
|
|
Term
|
Definition
the stream extraction operator |
|
|
Term
|
Definition
the stream insertion operator |
|
|
Term
how to promote
short a = 2000;
to int b? |
|
Definition
short a = 2000;
int b = a; |
|
|
Term
what can be used as a size declarator for a static array? |
|
Definition
a number (integer literal) or a const variable (named constant) |
|
|