Code Block gotoxy etc?



  • Hallo ich benutze jetzt den Code Block weiß aber nicht wie ich es hinkriege das gozoxy ,clrscr() ,textcolor funktioniert.

    Kann mir jemand helfen?



  • #include <windows.h>
    void gotoxy(int x,int y){
        COORD pos={x,y};
        SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
    }
    
    #include <cstdlib>
    void clrscr(void){
        system("CLS");
    }
    

    Für textcolor-dingsbums musst du halt google und msdn befragen...



  • danke ,aber textcolor und textbackground color is genau mein Problem google finde ich auch keine funktionen für und system("color") kann ihc auch nicht verwenden.Ich dachte an sowas wie conio2.h für dev gubts sowas auch für code blocks und wenn ja wie füge ich es ein



  • wenn du CodeBlocks mit MinGW Compiler benutzt sollte es genauso gehen wie mit Dev-C++



  • Mach's doch einfach mit der WinAPI.

    myconio.h:

    //* myconio.h *//
    
    #ifndef ____MYCONIO_H____
    	#define ____MYCONIO_H____
    
    	#include <windows.h>
    	#include <cstdlib>
    
    	class{
    	public:
    		static const unsigned short TEXT_BLUE=FOREGROUND_BLUE;
    		static const unsigned short TEXT_GREEN=FOREGROUND_GREEN;
    		static const unsigned short TEXT_RED=FOREGROUND_RED;
    		static const unsigned short TEXT_INTENSITY=FOREGROUND_INTENSITY;
    
    		static const unsigned short TEXTBACKGROUND_BLUE=BACKGROUND_BLUE;
    		static const unsigned short TEXTBACKGROUND_GREEN=BACKGROUND_GREEN;
    		static const unsigned short TEXTBACKGROUND_RED=BACKGROUND_RED;
    		static const unsigned short TEXTBACKGROUND_INTENSITY=BACKGROUND_INTENSITY;
    
    		void gotoxy(int x,int y){
    			COORD pos={x,y};
    			SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
    		}
    
    		void clrscr(void){
    			system("CLS");
    		}
    
    		void color(const unsigned short _colorattributtes){
    			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),_colorattributtes);
    		}
    	}conio;
    
    #endif
    

    main.cpp:

    #include "myconio.h"
    #include <iostream>
    
    int main(void){	
    	conio.color(conio.TEXTBACKGROUND_BLUE|conio.TEXTBACKGROUND_GREEN|conio.TEXTBACKGROUND_RED);
    	std::cout<<"Hello World!"<<std::endl;
    	std::cin.get();
    }
    


  • L'Équipe Tricolore schrieb:

    #include <cstdlib>
    void clrscr(void){
        system("CLS");
    }
    

    Aaargh! 👎



  • Läuft die Improved Console (http://ic.c-plusplus.net) denn unter CodeBlocks nicht? Hast du das schon versucht?

    MfG SideWinder


Anmelden zum Antworten