Re: Extend functionality of printf (Add colours)
- From: Tomás Ó hÉilidhe <toe@xxxxxxxxxxx>
- Date: Mon, 10 Nov 2008 09:31:35 -0800 (PST)
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.
.
- Follow-Ups:
- Re: Extend functionality of printf (Add colours)
- From: Richard Tobin
- Re: Extend functionality of printf (Add colours)
- References:
- Extend functionality of printf (Add colours)
- From: Tomás Ó hÉilidhe
- Re: Extend functionality of printf (Add colours)
- From: Bill Reid
- Extend functionality of printf (Add colours)
- Prev by Date: Re: Proper modularization technique
- Next by Date: Re: function return pointer of int?
- Previous by thread: Re: Extend functionality of printf (Add colours)
- Next by thread: Re: Extend functionality of printf (Add colours)
- Index(es):
Relevant Pages
|