Professional Documents
Culture Documents
Programming
• Introduction
• Declaration
• Concatenation, comparison operators, and [ ]
• Functions of the string class
• length, size, empty,
• insert, substr, replace, erase, clear, find
• Useful char functions in the C library <ctype.h>
Topic 9 – The String Class
INTRODUCTION
• If s is a string object, and you wish to obtain the value of the k-th
character in the string, you write: s[k];
• This feature makes string objects appear like arrays of chars.
string s= “Love”;
char c=s[0]; // c is ‘L’
c=s[1]; // c is ‘o’
c=s[2]; // c is ‘v’
STRING LENGTH AND EMPTY
C C++
• strcpy • =
• strcat • +=
• strcmp • ==, !=, <, >, <=, >=
• strchr, strstr • find()
• strrchr • rfind()
• strlen • size() or length()
CHAR FUNCTIONS IN C / C++
• Deitel, P., & Deitel, H. (2012). C++ How to Program.8th edition. New
Jersey: Prentice Hall. Chapter 18
• https://www.youtube.com/watch?v=LuFRDp9kKZ4
THANK YOU