Header files won't work in C [closed]

大憨熊 提交于 2019-11-28 13:09:59

textcolor() very old.(Perhaps borland c++ ?)

e.g. redefine like this

#include <Windows.h>
#include <stdio.h>
#include <conio.h>

void textcolor(unsigned short color){
    HANDLE hStdout;
    WORD wAttributes;
    CONSOLE_SCREEN_BUFFER_INFO csbi;

    hStdout = GetStdHandle(STD_OUTPUT_HANDLE);

    GetConsoleScreenBufferInfo(hStdout, &csbi);

    wAttributes = color ;
    if (color & 0x08) wAttributes |= FOREGROUND_INTENSITY ;

    SetConsoleTextAttribute(hStdout, wAttributes);
}

/*
#define FOREGROUND_BLUE      0x0001
#define FOREGROUND_GREEN     0x0002
#define FOREGROUND_RED       0x0004
#define FOREGROUND_INTENSITY 0x0008

#define BACKGROUND_BLUE      0x0010
#define BACKGROUND_GREEN     0x0020
#define BACKGROUND_RED       0x0040
#define BACKGROUND_INTENSITY 0x0080
*/

int main(int argc, char *argv[]){
    textcolor(1);
//  textcolor(FOREGROUND_BLUE);
    printf("FOREGROUND_BLUE \n");

    textcolor(4);
    printf("FOREGROUND_RED \n");

    textcolor(7);
    system("PAUSE");  
    return 0;
}

conio.h header file doesn't work with dev cpp because it is not part of c standard. http://www.bloodshed.net/dev/faq.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!