cpp:strings
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
cpp:strings [2017/05/08 06:00] – [Μεταβολή του αλφαριθμητικού] gthanos | cpp:strings [2017/05/08 07:06] – [Σύγκριση, αναζήτηση, εξαγωγή υπο-αλφαριθμητικών] gthanos | ||
---|---|---|---|
Line 226: | Line 226: | ||
==== Σύγκριση, | ==== Σύγκριση, | ||
- | | <code cpp></ | + | | <code cpp>const char* c_str() const;</ |
- | | <code cpp></ | + | | <code cpp>const char* data() const;</ |
- | | <code cpp></ | + | | <code cpp>size_t copy (char* s, size_t len, size_t pos = 0) const;</ |
- | | <code cpp></ | + | | <code cpp>size_t find (const string& str, size_t pos = 0) const; |
- | | <code cpp></ | + | size_t find (const char* str, size_t pos = 0) const; |
- | | <code cpp></ | + | size_t find (const char* str, size_t pos, size_t n) const; |
- | | <code cpp></ | + | size_t find (char c, size_t pos = 0) const; |
- | | <code cpp></code> | + | </ |
- | | <code cpp></ | + | | <code cpp> |
+ | size_t rfind (const char* str, size_t pos = npos) const; | ||
+ | size_t rfind (const char* str, size_t pos, size_t n) const; | ||
+ | size_t rfind (char c, size_t pos = npos) const; | ||
+ | </ | ||
+ | | <code cpp>string substr (size_t pos = 0, size_t len = npos) const;</ | ||
+ | | <code cpp>int compare (const string& str) const; | ||
+ | int compare (size_t pos, size_t len, const string& str) const; | ||
+ | int compare (const char* str) const; | ||
+ | int compare (size_t pos, size_t len, const char* str) const;</ | ||
+ | <code cpp cstring.cpp> | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | using namespace std; | ||
+ | int main () { | ||
+ | string str (" | ||
+ | char * cstr = new char [str.length()+1]; | ||
+ | strcpy (cstr, str.c_str()); | ||
+ | |||
+ | char * p = strtok (cstr," | ||
+ | while (p!=0) { | ||
+ | cout << p << ' | ||
+ | p = strtok(NULL," | ||
+ | } | ||
+ | delete[] cstr; | ||
+ | } | ||
+ | </ |
cpp/strings.txt · Last modified: 2021/04/27 04:45 (external edit)