Strings in C++

Strings in C++ - Strings in C+ To use "new"...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Strings in C++
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
To use "new" strings in C++ to use string CONSTANTS in double quotes, just use them - no library needed to use string variables and functions , you must #include <string> declare string variables assignment statement input with extraction operator output with insertion operator
Background image of page 2
String Operators and Methods concatenation dot notation length() substr() find()
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
concatenation operator is + at least one of the two operands must be a string variable example call: if name = “Bob”, expression name + "by Roberts" results in one string "Bobby Roberts" does not automatically put spaces in
Background image of page 4
length method Function length returns an unsigned integer value that equals the number of characters currently in the string    Function size returns the same value as function length You must use dot notation in the call to function length or size
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
no arguments, just () smallest return possible is 0 (empty string)
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

Strings in C++ - Strings in C+ To use &quot;new&quot;...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online