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

int main()
{
    HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
    WORD wOldColorAttrs;
    CONSOLE_SCREEN_BUFFER_INFO csbiInfo;

    /*
    * First save the current color information
    */
    GetConsoleScreenBufferInfo(h, &csbiInfo);
    wOldColorAttrs = csbiInfo.wAttributes;

    /*
    * Set the new color information
    */
    SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_INTENSITY);

    printf("This is a test\n");
    /*
    * Restore the original colors
    */
    SetConsoleTextAttribute(h, wOldColorAttrs);
}

 

相关文章:

  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
  • 2021-08-17
  • 2021-07-08
  • 2021-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-13
  • 2021-12-20
  • 2021-08-16
  • 2022-12-23
相关资源
相似解决方案