CharactersAndStrings - itzjac/cpplearning GitHub Wiki
strings
- This pointer
- Friend classes
- Static keyword
- Namespaces
- Enumerated Types
Null terminated string
String literals
const char[12]
Escape characters
Backslash + regular character
String functions
Including for the native char string functions.
- Length
- Equality
- Copying
- Addition
sprintf
transform numbers to Null terminated string
int sprintf(char *buffer, const char* format[,armgument] ...);
std::string
- Length
- String Operators (bool comparison)
- Addition
- Empty Strings (empty)
- Substrings (substr)
- Insertion (insert)
- Find (find)
- Replace (replace)
- Indexing using square brackets
- Conversion (c_str)
- getline
EXERCISES
Palindrome
To Upper
To Lower
String reverse
QUIZ
-
Code analysis strcpy char* x = 0; strcpy(x, "Hello World");
-
Code analysis find
-
Size in bytes of a c string
-
Code analysis static variable in function
void foo() { static int x = 0;
x++; ...
}
-
How to convert number to string representation
-
Code Analysis, value of s
std::string str = "abcdefghijklmnopqrstuvwxyz"; std::string s = str.substr(10, 5);
-
Code Analysis memory leak with c string char* getString() { char* str = "C++ is fun!";
return str;
}
-
Code Analysis strcmp
-
code analysis This pointer
-
Code analysis enums