/* ablauf.cpp

Beispiele für Ablaufkontrolle

for, do-while, if

(außerdem: String-Manipulation und cin/cout Streams)


@author David Reitter
@version 1.0

*/



#include <iostream.h>
#include <string.h>


int main()
{

	char eingabeZeichen;
    string gegruesster;
    string wort;

    int wert = 1;




    for (int i=1; i<=80; i++)
    {
     	cout << "*";
    }
    cout << endl << endl;


    do
    {
    	wert = wert*2;


     	cout << "Aktueller Wert = " << wert << "   weiter? ('e' fuer Ende) " << endl;


    	eingabeZeichen = cin.get();

    } while (eingabeZeichen!='E' && eingabeZeichen!='e');


    cout << "Moechten Sie noch jemanden gruessen?" << endl;

   // cin.getline(gegruesster, 49);

    do
    {
    	char buffer[100];

    	cin.getline(buffer, 99);

        wort = string(buffer);	// convert buffer into string

    	if (wort == "nein" || wort == "Nein")
        {
           	cout << "na gut, dann eben nicht!" << endl;
            break;
        }

        else if (wort == "ja" || wort == "Ja")
    		cout << "ok, und wen?" << endl;
        else if (wort != "")
        	break;


    } while(cin.good());	// go on, if there is an input left


    if (wort != "")
    {
    	while (true)
    	{
     		int r = wort.find("den ");

        	if (r == string::npos)
        		break;

    	    wort = wort.substr(r+4);

	    }
    	gegruesster=wort;
    }


    cout << endl << "Und hiermit geht ein schoener Gruss an " << gegruesster << endl;


    cout << "bitte Return druecken!" << endl;
    cin.get();

    return 0;




}

