Chapter 10 C++
To use the strlen function in a program, you must also write #include ________.
<cstring>
True/False: A test using the isupper function will return false if the argument is an uppercase character
False
True/False: Although C++ provides ample library functions to handle numeric values, we must write all of our own functions to manipulate character values.
False
True/False: C++ introduces a function named to_string that converts a numeric value to a string object.
False
True/False: The C++ complier performs strict array bounds checking when it encounters an array of characters
False
True/False: The strlen function returns a C-string's length and adds one for \0.
False
The isdigit function will return a true if its argument is a digit between 0 and 9.
True
True/False: By being able to pass arrays as arguments, you can write your own functions for processing C-strings.
True
True/False: The C++ library provides functions for converting a string representation of a number to numeric data type, and vice-versa.
True
True/False: The string class' front and back member function were introduced in C++ 11
True
True/False: When using the strcat function, you must be careful not to overwrite the bounds of an array.
True
You may use <, >, <=, >=, ==, and != relational operators to compare string objects.
True
What does this do? char str[50];
Will hold 49 characters and the null terminator
strstr(str1, str2)
finds the first occurrence of str2 in str1. Returns a pointer to match, or NULL if no match.
toupper()
if char is lowercase return character uppercased
To determine whether a character entered is a letter of the alphabet, use this function.
isalpha
Tests whether a character is a printable character:
isprint
This determines whether a character is whitespace
isspace
This function will return true if its argument is a printable character other than a digit, letter, or space.
isupunct
This function concatenates the contents of one C-String with another C-String.
strcat
isalnum
true if arg. is a letter or digit, false otherwise
isprint()
true if arg. is a printable character, false otherwise
ispunct()
true if arg. is a punctuation character, false otherwise
isupper()
true if arg. is an uppercase letter, false otherwise
islower()
true if arg. is lowercase letter, false otherwise
isalpha()
true if argument is a letter, false otherwise
isdigit()
true if digit: 0-9, false otherwise
isspace()
true if whitespace, false otherwise
The null terminators stands for this ASCII code
0
strcat(str, str2)
appends str2 to end of str1
This function accepts a C-string containing a number as its argument and returns the integer equivalent.
atoi
To define a C-String that will store students' last names of up to 25 characters in length, which is an appropriate statement?
char lastName[26];
This library function reverses the order of a C-string.
Nothing
tolower()
Returns a copy of this string converted to lowercase
strlen(str)
Returns length of C-string str
itoa(int, c-string, int)
converts 1st int parameter to a c-string, stores it in 2nd parameter, 3rd parameter is base of converted value
atoi(c-string)
converts C-String to an int value, returns the value
atof(c-string)
converts c-string to a double value
atol(c-string)
converts c-string to a long value, returns the value
strcpy(str1, str2)
copies str2 to str1
cin.getline()
receives input w/ whitespace and controls amount of input
This function accepts pointers to two c-strings and an integer argument, which indicates how many characters to copu from the second C-string to the first.
strncpy
Library function that fan find one C-string inside another is:
strstr
What practical application of thsi function is to allow a user to enter a response of 'y' or 'Y' to a prompt.
tolower or toupper