Hilfe!!!!!!!!!!!!



  • Hallo
    Ich wollte vor einiger zeit ein programm schreiben mit dem man reden kann.
    Allerdings sollten es keine festen befehle sein, auf die das programm dann antwortet, mann müsste also aus einem eingegebenem satz bestimmte bekannte wörter herrausfiltern Z.B. eingabe: hallo ;antwort: Hi
    oder
    eingabe: hallo blablabla ;antwort trotzdem: Hi

    Das habe ich mit so gemacht:

    char eingabe[1400];
    gets (eingabe);
    if (strstr(eingabe, "hallo" ) !=0)
    cout << ">Hi" <<endl;
    

    (diesen code zum herrausfiltern habe ich in irgendeinem forum gefunden)

    So weit bin ich bis jezt mit dem ganzen programm:

    #include <cstdio>
    #include <stdio.h>
    #include <conio.h>
    #include <string.h>
    #include <iostream>
    #include <cstdlib>
    #include <windows.h> 
    #include <shellapi.h>
    #include <stdlib.h>
    #include <fstream>
    #include <string>
    #pragma once
    #include <mmsystem.h>
    #include <winuser.h> 
    #include <tlhelp32.h>
    #pragma comment(lib,"winmm.lib")
    #include <process.h>
    using namespace std;
    
    int main(){
    
    start:
    char eingabe[1400];
    gets (eingabe);
    
    //Begrüssungen
    
    if (strstr(eingabe, "Hi" ) !=0)
    cout << ">hallo" <<endl;
    if (strstr(eingabe, "sers" ) !=0)
    cout << ">Hi" <<endl;
    else 
    if (strstr(eingabe, "wie gehts") !=0)
    cout << ">Gut" <<endl;	
    else
    if (strstr(eingabe, "hallo") !=0)
    cout << ">Hi" <<endl;
    else 
    if (strstr(eingabe, "servus") !=0)
    cout << ">Hallo" <<endl;
    else 
    if (strstr(eingabe, "off") !=0) 
    exit(1); 
    else 
    // musik
    if (strstr(eingabe, "spiel have a nice day") !=0) 
    PlaySound (TEXT ("2.wav"), NULL, SND_FILENAME | SND_ASYNC) ;
    else 
    if (strstr(eingabe, "stop") !=0)
    PlaySound(0,0,0); 
    else
    //special
    if (strstr(eingabe, "//show code") !=0)
    system("main.cpp");
    else
    //websites
    if (strstr(eingabe, "tintenherr.de") !=0)
    system("start http://tintenherr.de/");
    else
    //anderes
    if (strstr(eingabe, "herunterfahren") !=0)
    system("C:\\WINDOWS\\System32\\shutdown.exe -s -f -t 0 ");      
    
    goto start;
    return 0;
    
    }
    

    jezt wollte ich , dass wenn man z.b. "wie gehts eintippt", dass das programm dann erst "gut" antwortet, dann 2 sec wartet und dann fragt "und dir?" , worauf man dann entweder gut oder schlecht antworten kann.

    allerdings funzt es so wie ich es gemacht hab nicht:

    #include <cstdio>
    #include <stdio.h>
    #include <conio.h>
    #include <string.h>
    #include <iostream>
    #include <cstdlib>
    #include <windows.h> 
    #include <shellapi.h>
    #include <stdlib.h>
    #include <fstream>
    #include <string>
    #pragma once
    #include <mmsystem.h>
    #include <winuser.h> 
    #include <tlhelp32.h>
    #pragma comment(lib,"winmm.lib")
    #include <process.h>
    using namespace std;
    
    int main(){
    
    start:
    char eingabe[1400];
    gets (eingabe);
    
    //Begrüssungen
    
    if (strstr(eingabe, "Hi" ) !=0)
    cout << ">hallo" <<endl;
    if (strstr(eingabe, "sers" ) !=0)
    cout << ">Hi" <<endl;
    else 
    if (strstr(eingabe, "wie gehts") !=0)
    cout << ">Gut" <<endl;	
    	Sleep(2000);
    	cout<<"und dir?"<<endl;
    	char eingabe2[555555];
    	gets(eingabe2);
    	if (strstr(eingabe, "gut") !=0) 
    		cout<<"schön"<<endl;
    		goto start;
    	else
    	if (strstr(eingabe, "schlecht") !=0) 
    		cout<<"schade"<<endl;
    		goto start;
    else
    if (strstr(eingabe, "hallo") !=0)
    cout << ">Hi" <<endl;
    else 
    if (strstr(eingabe, "servus") !=0)
    cout << ">Hallo" <<endl;
    else 
    if (strstr(eingabe, "off") !=0) 
    exit(1); 
    else 
    // musik
    if (strstr(eingabe, "spiel have a nice day") !=0) 
    PlaySound (TEXT ("2.wav"), NULL, SND_FILENAME | SND_ASYNC) ;
    else 
    if (strstr(eingabe, "stop") !=0)
    PlaySound(0,0,0); 
    else
    //special
    if (strstr(eingabe, "//show code") !=0)
    system("main.cpp");
    else
    //websites
    if (strstr(eingabe, "tintenherr.de") !=0)
    system("start http://tintenherr.de/");
    else
    //anderes
    if (strstr(eingabe, "herunterfahren") !=0)
    system("C:\\WINDOWS\\System32\\shutdown.exe -s -f -t 0 ");      
    
    goto start;
    return 0;
    
    }
    

    was habe ich falsch gemacht????

    PS:Ich benutze Microsoft Visual C++ express 2010
    PS:Ich kenne mich mit C++ noch nicht so gut aus



  • Antwort auf deine Frage: so ziemlich alles

    Da wäre:
    - sinnfreier Titel
    - kein Minimalbeispiel
    - grauenhafter Code
    - keine Fehlerbeschreibung
    - keine konkrete Frage (außer "was habe ich falscht gemacht?" - darauf antworte ich dir gerade)

    Behebe die aufgezählten Punkte, dann kannst du evtl. eine sinnvolle Antwort erwarten



  • das is ja doof !!!!!!!!


  • Mod

    Du brauchst Hilfe?

    Kritikpunkte beheben, dann nochmal neu versuchen. Mit so einem Thread wie diesem bekommst du keine brauchbare Antwort, daher mach ich hier mal zu.


Anmelden zum Antworten