öäü richtig wiedergeben in einer textausgabe ?



  • Ich bekomme beim fertigen programm,
    wenn ich text ausgeben möchte statt den
    äöü nur sinnloßes zeugs,
    wer weis rat ?



  • //Farbe und Umlaute mit Windows-Konsole
    #include <windows.h>
    #include <conio.h>
    #include <cstdio>
    #include <iostream>
    using namespace std;
    
    void textcolor(int color)
    { 
        SetConsoleTextAttribute( ::GetStdHandle(STD_OUTPUT_HANDLE), color ); 
    } 
    
    /*
    // Auszug aus conio.h:
    typedef enum
    {
        BLACK,
        BLUE,
        GREEN,
        CYAN,
        RED,
        MAGENTA,
        BROWN,
        LIGHTGRAY,
        DARKGRAY,
        LIGHTBLUE,
        LIGHTGREEN,
        LIGHTCYAN,
        LIGHTRED,
        LIGHTMAGENTA,
        YELLOW,
        WHITE
    } COLORS;const int WHITE = 15;
    */
    
    int main()
    {
      textcolor(RED);
      cout << "Das ist rot" << endl;
    
      textcolor(BLUE);
      cout << "Das ist blau" << endl;
    
      textcolor(GREEN);
      cout << "Das ist gr" << char(129) << "n" << endl; // Umlaut ü
    
      textcolor(WHITE);
      cout << "Das ist weiss" << endl << endl;
    
      for(int i=0; i<16; ++i)
      {
          textcolor(i); 
          cout << "Das ist Farbe: " << i << endl;
      }
      cout << endl << "H" << char(148) << "fliche G" << char(132) 
           << "ste im Gr" << char(129) << "nen haben Spa" << char(225) << "." << endl; 
      cout << char(132) << char(148) << char(129) << char(225) << endl;     
    
      getch();
    }
    


  • dankeschön, es funktioniert auch,
    nur bitte ich versteh net ganz was char damit zu tun hatt.
    Die zahl hinter der klammer kann ich mir schon erklären



  • Dieser Thread wurde von Moderator/in HumeSikkins aus dem Forum C++ in das Forum DOS und Win32-Konsole verschoben.

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

    Dieses Posting wurde automatisch erzeugt.



  • C++Neueinsteiger schrieb:

    [...] nur bitte ich versteh net ganz was char damit zu tun hatt. [...]

    Damit nicht die basic_ostream Methode basic_ostream& operator<<( int _Val ) aufgerufen wird, welche 148 (ö), 132 (ä), und 129 (ü) als Zahlen und nicht als Zeichen ausgeben würde.

    Greetz, Swordfish


Anmelden zum Antworten