47 lines
1.0 KiB
C++
47 lines
1.0 KiB
C++
#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;
|
|
}
|