Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Setting color of text with printf()

Setting color of text with printf()

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpvisual-studiotutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jerry1211a
    wrote on last edited by
    #1

    Hello. I am setting up a C console application under VS.net. I have various printf statements. If some type of error condition occurs I would like to change the color of the text to RED that the printf statement prints to the console. I dont know how to change the colors for this situation. Can someone help me with this? :() Jerry

    D 1 Reply Last reply
    0
    • J jerry1211a

      Hello. I am setting up a C console application under VS.net. I have various printf statements. If some type of error condition occurs I would like to change the color of the text to RED that the printf statement prints to the console. I dont know how to change the colors for this situation. Can someone help me with this? :() Jerry

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      printf() knows nothing of color. Check out SetConsoleTextAttribute() and WriteConsole() instead.


      "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

      "There is no death, only a change of worlds." - Native American Proverb

      J 1 Reply Last reply
      0
      • D David Crow

        printf() knows nothing of color. Check out SetConsoleTextAttribute() and WriteConsole() instead.


        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

        "There is no death, only a change of worlds." - Native American Proverb

        J Offline
        J Offline
        jerry1211a
        wrote on last edited by
        #3

        Ok thanks, I got it all working. :) Jerry

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups