Comp Sci Ch 5 Ch 6 Flashcards
What does equality mean with string comparisons
same number of characters and each corresponding character is identical
what does relational mean with string comparisons
begins at index 0 and compares each character until the evaluation results in false, or end of string is reached
What do you have to include when you want to use character operations
include <cctype></cctype>
What are the 5 functions when working with characters and what do they do
isalpha(c) - true if c is a letter
isdigit(c)- true if c is a number 0-9
isspace(c)- true if whitespace or endl;
toupper(c)- returns the uppercase version of c
tolower(c)- returns the lowercase version of c
How to access an input string
getline(cin, name);
How do you access a string character
name.at(x)
if you know length, how do you find index
length - 1w
what do you use to find the string size
name.size()
how can you append one string to another one
string1.append(string2)
what are test cases you can use when testing your code involving a string
0 indexes or the start or end
when to use while loop vs for loop in string code
while loop for when user to providing sentinel value
for loop when we know end/stop
how do you find an item and how in a specific index range
string.find(item)
string.find(item, index)
what is returned when an item is not found
string::npos
how to get a substring starting at an index and with having length characters
string.substr(index, length)
-if no length goes to end
how to add a character to the end of a string
string.push_back(c)