problem mit 16 bit compiler



  • wenn ich mit string arbeite kommt dieser fehler

    cd C:\cpp
    wmake -f C:\cpp\hihi.mk -h -e C:\cpp\hihi.com
    wpp DM\BIN\Michael.cpp -i=C:\WATCOM\h;c:\Dev-Cpp\include\c++\3.4.2\backward;c:\Dev-Cpp\include -w4 -e25 -zq -od -d2 -bt=dos -ms -xs -xr
    DM\BIN\Michael.cpp(23): Error! E157: col(8) left expression must be integral
    DM\BIN\Michael.cpp(23): Note! N717: col(8) left operand type is 'std::istream watcall (lvalue)'
    DM\BIN\Michael.cpp(23): Note! N718: col(8) right operand type is 'std::basic_string<char,std::char_traits<char>,std::allocator<char>> (lvalue)'
    Error(E42): Last command making (C:\cpp\Michael.obj) returned a bad status
    Error(E02): Make execution terminated
    Execution complete

    mein code sieht so aus:

    int main()

    std::string s = "rech";
    std::string hallo;
    cin>>hallo;

    if( hallo == s )
    {
    cout<<"hallo";
    }

    hat vielleicht jemand eine lösung? beim open watcom compiler hab ich gelesen das es schwierigkeiten mit string geben könnte, muss das aber leider benutzen, geht nicht anders.



  • Zeig doch mal den vollständigen Code - inklusive aller #include's.

    PS: sfds



  • hier mein code

    #include <cstdlib>      
    #include <iostream>
    #include <string>
    #include <fstream>
    
    using namespace std;
    
    int main()
    {
    
        std::string s = "rech";
        std::string hallo;
        cin>>hallo;
    
        if( hallo == s )
                 {
    
                                 cout<<"Rechner: ";
    							 std::string a = "rech";
                                 int art;
                                 cin>>art;
                                 if(art==1)
                                 {
                                             cout<<"Die erste Zahl eintippen für die Addition\n\n";
                                             cout<<"Zahl 1: ";
                                             int zahl, zahl2, ergebnis;
                                             cin>>zahl;
                                             cout<<"Jetzt die Zweite Zahl bitte.\n\n";
                                             cout<<"Zahl 2: ";
                                             cin>>zahl2;
    										 ergebnis = zahl + zahl2;
                                             cout<<"Die Summe ist: "<<ergebnis<<".\n";
                                             system("PAUSE");
    }
    }
    }
    


  • Mein Compiler (gcc) schluckt den ohne Probleme. Bist Du sicher, dass das und genau das der Code ist, den Du Deinem Compiler übergibst ?
    Nicht irgendwo noch ein include oder Modul oder ... mehr ?

    Gruß,

    Simon2.



  • Ich benutze ja nicht den gcc sondern Open Watcom und dort gibt es Probleme mit string, hab ich gelesen. Aber vielleicht arbeitet ja auch noch jemand anderes hier mit Open Watcom und kennt sich damit aus? Mit DevC++ geht der Code auch wunderbar durch, bloß brauche ich einen 16 Bit Compiler und DevC++ ist keiner.

    Wenn ich alle Variablen mit int und zahlen mache, dann klappt es wunderbar, wieso geht das dann nicht mit Wörtern?



  • Dann schau doch mal in die Compiler-Hilfe, was der Hersteller zu std::string zu sagen hat.

    (PS: Auch wenn's hart ist, wenn es gar nicht anders geht, mußt du wohl doch auf char-Arrays ausweichen)



  • Hab jetzt mal mit char ausprobiert und es klappt immer noch nicht.

    Diese Fehlermeldung kommt jetzt noch.

    cd C:\cpp
    wmake -f C:\cpp\hihi.mk -h -e C:\cpp\hihi.com
    wlink name hihi d all SYS dos com op m libf cstart_t op maxe=25 op q op symf @hihi.lk1
    Error! E2020: size of group DGROUP exceeds 64k by 6082 bytes
    Error! E2083: cannot reference address 115f:0000 from frame 0000
    Error! E2083: cannot reference address 115f:0000 from frame 0000
    Error! E2083: cannot reference address 115f:01d2 from frame 0000
    Error! E2083: cannot reference address 115f:01d2 from frame 0000
    Error(E42): Last command making (C:\cpp\hihi.com) returned a bad status
    Error(E02): Make execution terminated
    Execution complete
    

    mein code sieht jetzt so aus

    #include <cstdlib>      
    #include <iostream>
    #include <string>
    #include <fstream>
    
    using namespace std;
    
    int main()
    {
    
        char hallo[10];
        cin>>hallo;
    
        if( hallo == "hier" )
                 {
    
                                 cout<<"Rechner: ";
                                 char a[10];
    
                                 cin>>a;
                                 if(a=="rech")
                                 {
                                             cout<<"Die erste Zahl eintippen für die Addition\n\n";
                                             cout<<"Zahl 1: ";
                                             int zahl, zahl2, ergebnis;
                                             cin>>zahl;
                                             cout<<"Jetzt die Zweite Zahl bitte.\n\n";
                                             cout<<"Zahl 2: ";
                                             cin>>zahl2;
                                             ergebnis = zahl + zahl2;
                                             cout<<"Die Summe ist: "<<ergebnis<<".\n";
                                             system("PAUSE");
    }
    }
    }
    


  • Erstens: Wenn du char-Arrays mit String-Literalen vergleichen willst, mußt du strcmp() verwenden.

    Zweitens: Schau mal in der Hilfe/Referenz/Dokumentation des Compilers nach, was der Fehler E2020 bedeutet und wie du ihn beheben kannst.



  • Dieser Thread wurde von Moderator/in CStoll aus dem Forum C++ in das Forum Compiler- und IDE-Forum verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.



  • Bleibtreu schrieb:

    Error! E2020: size of group DGROUP exceeds 64k by 6082 bytes

    du musst wohl ein anderes memory model wählen, 'large' oder 'huge'.
    (und dann eventuell einige objekte und funktionen als __far bzw. __huge deklarieren, DOS hat so eine komische, segmentierte speicherlogik).

    btw: eventuell kommst du drum herum, wenn du kein C++ verwendest, sondern reines C (wenn's bei dir möglich ist), das spart platz.
    🙂



  • hab bei mir jetzt 32 bit eingestellt, aber es läuft nicht so wie ich das will.

    #include <cstdlib>      
    #include <iostream>
    #include <fstream>
    
    using namespace std;
    
    int main()
    {
    
    	cout<<"Hier einen Befehl eintippen.\n\n";
    	cout<<"Befehl: ";
    	char hier[5] = "h";
    	cout<<"\n\n\n"<<hier<<"\n\n\n";
    	char hallo[5];
        cin>>hallo;
    
        if( hallo == hier )
                 {
    
                                 cout<<"Rechner: ";
                                 char a[10];
    
                                 cin>>a;
                                 if(a == "rech")
                                 {
                                             cout<<"Die erste Zahl eintippen für die Addition\n\n";
                                             cout<<"Zahl 1: ";
                                             int zahl, zahl2, ergebnis;
                                             cin>>zahl;
                                             cout<<"Jetzt die Zweite Zahl bitte.\n\n";
                                             cout<<"Zahl 2: ";
                                             cin>>zahl2;
                                             ergebnis = zahl + zahl2;
                                             cout<<"Die Summe ist: "<<ergebnis<<".\n";
                                             system("PAUSE");
    }
    }
    }
    

    Der speichert zwar das (h) in der Variable (hier), aber wenn ich dann auf der Konsole (h) eintippe, dann stürzt mein Programm ab, weiß nicht warum und was ich dagegen machen kann.



  • Wie ich schon vorhin gesagt habe - char-Arrays kannst du nicht mit == vergleichen (eigentlich schon, aber das liefert keine sinnvollen Ergebnisse), sondern mit man: strcmp(). Und dann solltest du vielleicht mal dazusagen, wo und mit welcher Meldung das Programm abstürzt.

    (ich vermute eher, daß das Programm sauber durchläuft, aber sich am Ende das Konsolenfenster schließt, bevor du etwas vom Ergebnis mitbekommst)


Anmelden zum Antworten