Re: Extend functionality of printf (Add colours)



On Nov 10, 9:38 pm, "Bill Reid" <hormelf...@xxxxxxxxxxxxxxxx> wrote:

Just curious...have you ever heard of something called "conio.h"

There's an easier way. For instance on Linux, you can do:

printf("\033[37mHello!");

They call them escape sequences or something like that.

I've already got the code written and working for Linux, and now I'm
writing it for Windows. I had thought that under Windows I might be
able to do:

printf("$e[37mHello!");

but I tried it just there and it didn't work (as far as I know it
worked in DOS). I know under Windows there's a Win32 API function
called "SetConsoleTextAttribute", but I was hoping the above would
work because I'm not too keen on explicitly linking with gdi32.lib,
nor am I keen on including the whore of a file that is <windows.h>.
Anyone know another way of changing the console text colour in
Windows?

Just as an aside, I'm also writing a cross-platform library for
dealing with raw sockets. I pretty much have it simplified to four
functions:

OpenRawsock
SendEthernetFrame
RecvEthernetFrame
CloseRawsock

So far I have it working for Linux and Windows (The Linux version used
Berkeley Sockets and the Windows version uses pcap because WinSock no
longer allows raw sockets). Anyone who's interested can e-mail me.
.



Relevant Pages

  • Re: Future of IT in Lebanon
    ... working knowledge of Indian programmers DNA, nor of their intuitive Java ... > So Longhorn is not an experiment and Linux is an experiment? ... another chapter in the Windows story, and the Microsoft marketing machine is ... > application opens, Check the about, it says Microsoft Visual Basic 6.3. ...
    (soc.culture.lebanon)
  • FTP DOWNLOAD! More than 6500 CRACKED SOFTWARE(CAD,CAE,CAM,ED
    ... Autodesk Architectural Desktop 2005 ... DASSAULT SYSTEMES CAA ENOVIA LCA V5R13 ... ALTAIR.OPTISTRUCT V5.1 for LINUX ... ANSYS V8.0 FOR WINDOWS ...
    (microsoft.public.dotnet.framework.adonet)
  • Linux for Senior Citizens
    ... Linux for Senior Citizens ... For such people, I believe, Windows really is a better option: ... The kernel manages all the hardware and also looks after all running ...
    (uk.people.silversurfers)
  • Re: Future of IT in Lebanon
    ... It's the same Linux code base. ... Microsoft Office on a Windows server, it will install and run fine, the main ...
    (soc.culture.lebanon)
  • Re: [SLE] Developing a Real Time Data System
    ... The KBasic License is valid for both operating systems: Windows and Linux. ... Modern BASIC language ... chapters learning about the programming language. ...
    (SuSE)