How can we help?

You can also find more resources in our Help Center.

C++ Chapter 3

terms and definition
STUDY
PLAY
arguments
the numbers inside the parentheses in a function.
Implicit type conversion
One data type outranks another if it can hold a larger number.
type cast expression
lets you manually promote or demote a value. the general format for a type cast expression is: static_cast<datatype>(value)
named constants
like a varialbe, buts its content is read-only and cannot be changed while the program is running.
define directive
used the same way as a named constant
combined assignment operators
used to adjust values by replacing the value that was previously storeed there. (number = number-1 is equivalent to number -= 1
formatting
the way a value is printed
setw
offers a way of specifying the minimum number of spaces to use for each number.
setprecision
this maniuplator rounds a number to a certain amount of significant digits
fixed
this manipulator indicates that a floating-point output should be printed in decimal notation. When used in conjuction with the setprcesision manipulator it specifies the number of digits to be displayed after the decimal point of a loating-point number, rather than the total number of digits to be displated.
showpoint
shows the decimal point regardless of if it is needed or not
getline
a special funtion that will read in an etnire line, including leading and embedded spaces, and store it in a string object. getline (cin, name);
cin.get
used same as getline, but with a character and not a string
cin.ignore
this funtion tells the cin object to skip characters in the keyboard buffer. cin.ignore (n, c). the arguments shown in the parentheses are optional. if used, n is an integer and c is a character. they tell cin to skip n number of characters, or until the character c is encountered. Statements that mix cin >> and cin.get can be repaired by inserting a cin.ignore statement after the cin >> statement
C-string
the way to create a string variable in C, a string defined in this manner is called a C-string. char word [10] = "Hello";
size declarator
tells how many memory cells to set up to hold the characters in the C-string
strcopy
a function that is used to copy the contents of one string into another. strcopy (name1, sebastien) this copies Sebastien to name1.
cin.width
used to prevent buffer overrun when entering a string to be used with a C-string. cin.width(5) accounts for the \n at the end, meaning it will only hold up to 4 characters in it
rand()
the cstdlib is required for this function and is used to generate a random number from an algorithm. But because it is an algorithm, the numbers are the same each time the program runs
fstream
a file needed that contains all the definitions necessary for file operations.
file stream objects
the stream that must be identified prior to copying information to a file. Either ofstream, ifstream, or fstream. After identifying the stream, directly after it goes the file you would like to output/input to.
ofstream ofile;
Opening the file
ofile.open("demoflile.txt")