initial checkin from subversion
This commit is contained in:
46
strings.cc
Normal file
46
strings.cc
Normal file
@@ -0,0 +1,46 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int erg;
|
||||
size_t pos;
|
||||
string text1;
|
||||
string text2;
|
||||
string nachrichten;
|
||||
|
||||
cout << "Geben Sie zwei Strings ein\n";
|
||||
cin >> text1 >> text2;
|
||||
|
||||
erg = text1.compare(text2);
|
||||
cout << endl;
|
||||
if (erg == 0)
|
||||
nachricht = "Die Zeichenketten sind gleich!";
|
||||
else
|
||||
if (erg > 0)
|
||||
nachricht = "Die erste Zeichenkette ist größer!";
|
||||
else
|
||||
nachricht = "Die zweite Zeichenkette ist größer";
|
||||
cout << "\t" << nachricht << "\n\n";
|
||||
|
||||
cout << "Text 2 wird in dern String \"Nachricht\" kopiert" << endl;
|
||||
nachricht = text2;
|
||||
cout << "\t Nachricht = " << nachricht << endl << endl;
|
||||
|
||||
cout << "Text1 wird auf Vorkommen des Buchstabens i überprüft" << endl;
|
||||
|
||||
pos = nachricht.find("i");
|
||||
pos++;
|
||||
|
||||
if (pos)
|
||||
{
|
||||
cout << "i Wurde in Strng " << nachricht << " an Position " << pos << " gefunden " << endl << endl;
|
||||
}
|
||||
else
|
||||
cout << " i kommt in " << nachricht << " nicht vor \n\n";
|
||||
|
||||
cout << "Text2 wird an Text1 angehängt" << endl;
|
||||
text1.append(text2);
|
||||
cout << "\tErgebnin = " << text1 << "\n\n";
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user