Lecture 5
Lecture 5
Paradigms in C++
CSCI 3142
By
Priyanka Samanta
String
• C++ supports two forms of strings:
• C style strings and
• C++ string class
•This null character marks the end of a C-style string, and many string
processing functions depend on the presence of this marker to do their work.
A better way to initialize a char array
You may not like always having to worry about adding the null char
•String literals
char iknowmysize[6] = “hello”; // only 5 chars, null char added implicitly
char letcompilercount[] = “hello”; // either 6 or above, or leave blank
• First argument is the name of the string (address of first element of string) and
second argument is the maximum size of the array.