Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Anonymous
unregistriert
C-/C++-Quelltext |
|
1 |
char array[1][2]={"Sprite","Cola"}; |
Anonymous
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 |
#include <iostream> #include <string> using namespace std; int main(void) { string string_1 = "Hallo!"; string string_2 = string_1; cout<< string_2 <<endl; cin.get(); } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
#include <iostream> #include <string> using namespace std; int main(void) { string string_1 = "Hallo!"; string string_2 = ""; string_2 = string_2 + string_1; cout<< string_2 <<endl; cin.get(); } |
Anonymous
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
// /////////////////////////////////////////////////////////////////////////// // GLOBAL // // Returns a new string resulting from replacing all occurrences of 'what' // in 'value' with 'replace'. // // \param value: String with occurrences to replace. // \param what: String to replace. // \param replace: Replacement for 'what'. // \result: New string with all replaced occurrences. // /////////////////////////////////////////////////////////////////////////// std::string replace (const std::string& value, const std::string& what, const std::string& replace) { std::string result = value; for (std::string::size_type i = 0, position = 0; (i = result.find (what, position)) != std::string::npos; ) { result.replace (i, what.size (), replace); position = i + replace.size (); } return (result); } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 |
std::string string_mit_platzhaltern = "$hello$, $world$"; string_mit_platzhaltern = replace (string_mit_platzhaltern, "$hello$", "Hallo"); string_mit_platzhaltern = replace (string_mit_platzhaltern, "$world$", "liebe Welt!"); std::cout << string_mit_platzhaltern << std::endl; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
std::string CopySubstring( const std::string& str, const std::string::value_type& c, std::string::size_type start = 0 ) { std::string result = ""; std::string::size_type i0, i1; i0 = i1 = std::string::npos; if ( ( i0 = str.find( c, start ) )!= std::string::npos ) { ++i0; i1 = str.find( c, i0 ); } if ( i0 != std::string::npos && i1 != std::string.npos ) result = str.substr( i0, i1-i0 ); return result; } |
Anonymous
unregistriert
Zitat von »"unsigned long"«
David_pb
Sollst dich schämen Er hätte so die find-Methode kennengelernt. ;-) Aber egal.
Anonymous
unregistriert
Zitat
Ich hab mir schon die Klasse string angeschaut, aber ich weiß nicht welche Funktion ich nehmen soll
Werbeanzeige