12- strings Flashcards

1
Q

string

A

specific constructs that are designed for processing sequences of characters
before using, include string header: #include <string>don’t use string.h
as well as using std::string;
string declaration: string mystr;
value assignment at declaration:
string mystr(”Hello”);
string mystr2=”Hello”;</string>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

lexicographically

A

how strings are ordered
letters in the alphabet are in the increasing order
longer word (with the same characters) is greater than shorter word

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

size()

A

current string size (number of characters currently stored in string
length() is same

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

max_size()

A

maximum number of characters in string allowed on this computer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

empty()

A

true if string is empty

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

insert(start, substring)

A

inserts substring starting from position start
string s=”place”;
cout &laquo_space;s.insert(1, ”a”); // produces ”palace”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

replace (start, number, substring)

A

replaces number of characters starting from start with substring the number of characters replaced need not be the same
string s=”Hello”;
s.replace(1,4, ”i, there”); // produces ”Hi, there”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

append(string2)

A

appends string2 to the end of the string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

erase(start, number)

A

removes number of characters starting from start

How well did you know this?
1
Not at all
2
3
4
5
Perfectly