hilfe bei gotoxy!



  • 😞 hallo 😢

    hab mal folgenden code gehabt:

    #include <iostream>
    #include <conio.h>
    
    using namespace std;
    
    HANDLE hOuput = GetStdHandle(STD_OUTPUT_HANDLE);
    
    void gotoxy (int x, int y)
    {
        COORD pos;
        pos.X = x;
        pos.Y = y;
        SetConsoleCursorPosition(hOuput,pos);
    }
    
    int main()
    {
    gotoxy(5,5);
    cout<<"hallo welt";
    return 0;
    }
    

    brauche diesen code für linux ....



  • Am einfachsten mit ANSI-Escape-Sequenzen.



  • ich hab in netzt folgenden code gefunden:

    #include <iostream> 
    #include <cstdlib>
    #include <stdio.h>
    #include <string.h>
    
    using namespace std;
    unsigned char d =  200;
    
    int gotoxy(int x, int y) 
    {
     char essq[100]; 
     char xstr[100]; 
     char ystr[100]; 
    
     sprintf(xstr, "%d", x);
     sprintf(ystr, "%d", y);
     essq[0] = '\0';
     strcat(essq, "\033[");
     strcat(essq, ystr);
     strcat(essq, "d");
     strcat(essq, "\033[");
     strcat(essq, xstr);
     strcat(essq, "G");
     printf("%s", essq);
     return 0;
    }
    
    int main()
    {
    system("clear");
    gotoxy(10,10);
    cout<<"Hallo World";
    return 0;
    }
    

    😃 have a nice day ...



  • Öhm, der Code ist ziemlich mies.

    Nimm lieber

    #include <iostream>
    
    void gotoxy(unsigned x, unsigned y) {
      std::cout << "\033[" << y << "d\033[" << x << 'G';
    }
    
    int main() {
      gotoxy(10, 10);
      std::cout << "Hallo Welt\n";
    }
    

Anmelden zum Antworten