C++ STRINGS Flashcards
contains a collection of characters surrounded by double quotes
STRING
you must include an additional header file in the source cod, the <string> library</string>
STRING
CAN ALSO be DEFINED AS CHARACTER ARRAY
STRING
The + operator can be used between strings to add them together to make a new string. This is called concatenation
String concatenation
C++ uses the + operator for both addition and concatenation. Numbers are added. Strings are concatenated
String concatenation
FORMAT: strName.length();
LENGTH FUNCTION
FORMAT: getline(cin, strName, [charDelimiter]);
INPUT FUNCTION
FORMAT: cin.ignore([noOfChar], [charDelimiter]);
IGNORE FUNCTION
FORMAT: strName.substr(index,[count]);
SUBSTRING FUNCTION
FORMAT: strName.insert(index, strToInsert);
INSERT FUNCTION
FORMAT: strName.replace(index, count, strToReplace);
REPLACE FUNCTION
FORMAT: strName.erase(index, count);
ERASE FUNCTION
FORMAT: strName.find(strToFind, [index]);
FIND FUNCTION
FORMAT: strName.assign(count, charToAssign);
ASSIGN FUNCTION
– getch();
- A PRE-DEFINED FUNCTION IN “CONIO.H”
- READS A SINGLE CHARACTER FROM THE KEYBOARD AND IT DOESN’T ECHO TO THE CONSOLE AND DOESN’T WAIT FOR AN ENTER TO STORE IN A VARIABLE.
GET CHARACTER FUNCTIONS