(urgent) printf format question

A

Andy

Hi

How can I change the color of text output by printf? Are there special \
control characters?

Quick answer appreciated, thanks.
 
E

Eric Sosman

Hi

How can I change the color of text output by printf? Are there special \
control characters?

Quick answer appreciated, thanks.

This is Question 19.4 on the comp.lang.c Frequently Asked
Questions (FAQ) page at <http://www.c-faq.com/>.

It's always a good idea to read the FAQ before posting, and
in this case you'd have had your answer considerably sooner had
you done so ...
 
S

spinoza1111

     This is Question 19.4 on the comp.lang.c Frequently Asked
Questions (FAQ) page at <http://www.c-faq.com/>.

     It's always a good idea to read the FAQ before posting, and
in this case you'd have had your answer considerably sooner had
you done so ...

The cite only re-asks the question. The answer is that C does not give
the OP a way but certain control characters may have effects over and
above C that can color text. These can be entered with control
characters and may be documented in the reference manual for the OP's
printer. Alternatively, he may have to learn post-script or Rich Text
Format codes.

Format codes can send anything, not just printable characters, to
printers. Depending on the make and model, the printer may do many
different things: print colors, skip to the next page without printing
anything, jam, refuse to print documents until Kingdom Come or a cold
reboot, or catch fire. It all depends on the manufacturer, although in
recent years, Postscript has become standard. Rotsa ruck rearning
postscript: it is a completely stack based Reverse Polish language if
memory serves.

The whole philosophy of "FAQ" is micro-Fascism, since it pretends that
dialogue, of which questions are a part, is a waste of time. I for one
am sick to death of the attitude that understanding can be reified.

C is not old Basic in which various compiler-interpreters gave the
programmer the ability to draw crude colored pictures and tootle
monophonic songs. C, considered as a demiurge, does not care about the
color of characters.
 
A

Andy

Eric said:
This is Question 19.4 on the comp.lang.c Frequently Asked
Questions (FAQ) page at <http://www.c-faq.com/>.

It's always a good idea to read the FAQ before posting, and
in this case you'd have had your answer considerably sooner had you done
so ...

OK, but this FAQ is completely useless on this point for Windows users.
Actually, looking through it, most of it seems outdated, aimed at DOS/
ancient versions of Unix. I don't think I'll bother with it as a first
port of call, thanks very much.

Answer to my original question still needed! Win32 console application.
 
T

Tim Streater

Andy said:
OK, but this FAQ is completely useless on this point for Windows users.
Actually, looking through it, most of it seems outdated, aimed at DOS/
ancient versions of Unix. I don't think I'll bother with it as a first
port of call, thanks very much.

Answer to my original question still needed! Win32 console application.

Have you asked on a Windows NG?
 
I

Ian Collins

OK, but this FAQ is completely useless on this point for Windows users.

Because "this point" is beyond the scope of standard C.
Actually, looking through it, most of it seems outdated, aimed at DOS/
ancient versions of Unix. I don't think I'll bother with it as a first
port of call, thanks very much.

Then you are ignoring a useful resource.
Answer to my original question still needed! Win32 console application.

So ask on a windows group.
 
K

Keith Thompson

Andy said:
OK, but this FAQ is completely useless on this point for Windows users.
Actually, looking through it, most of it seems outdated, aimed at DOS/
ancient versions of Unix. I don't think I'll bother with it as a first
port of call, thanks very much.

Answer to my original question still needed! Win32 console application.

This is not a Windows group. There is no C answer to your question;
the C language doesn't define any way to change the color of output
characters; C runs on many systems that have no such capability.
The FAQ provides some system-specific examples, but it can't
provide all of them.

I wouldn't be surprised if some of the suggestions in the FAQ actually
worked on Windows, but I couldn't tell you for sure.

I suggest asking in comp.os.ms-windows.programmer.win32.
 
E

Eric Sosman

OK, but this FAQ is completely useless on this point for Windows users.

It's surprising to learn that all those Windows implementations
of curses have disappeared. They used to roam the wide prairies in
their millions, shooting buffalo and eating passenger pigeons. But
now, you say, they've gone extinct while I wasn't looking. Sad.
I don't think I'll bother with it as a first
port of call, thanks very much.

Fair enough. For my part, I won't answer next time you ask a
question that's in the FAQ.
 
T

Tim Harig

I will start by warning you that this question is asked a *lot* and is
therefore a signal that whoever is asking hasn't really done much research
to solve thre problem for themselves. Most people don't like to
continually answer the same questions over and over again. They wrote it
once and it usually doesn't take much to google for the answer.

You should also know that adding "urgent" to your subject will almost
always cause you grief and make getting your answer anything but brief.
Mostly, it just tends to piss people off. This may come as a revelation to
you; but, your problems are no more important then any body elses. In
fact, because of the way that you asked your question, we tend to feel that
it is less relevant.
OK, but this FAQ is completely useless on this point for Windows users.

No, as has already been pointed out, it told you enough to know that C does
very little to handle platform specific features. The question you are
asking is *not* specifically C related.
Actually, looking through it, most of it seems outdated, aimed at DOS/
ancient versions of Unix. I don't think I'll bother with it as a first
port of call, thanks very much.

You didn't specify Windows in your original post. If you are not getting
the answers that you were expecting, then you need to change the way you
are asking your question. If you haven't already seen this URL many times,
your method for asking questions is likely to cause many to point you to
it:

http://catb.org/~esr/faqs/smart-questions.html
Answer to my original question still needed! Win32 console application.

1. I have already mentioned that Google would have given you your answer
quite easily:

http://www.google.com/search?q=win32+console+color

2. Since this is a Microsoft product, I would have suggested looking there
first. You can get almost any information that you need from their
MSDN website. In your case:

http://msdn.microsoft.com/en-us/library/ms682010(v=VS.85).aspx
 
K

Keith Thompson

Andy said:
OK, but this FAQ is completely useless on this point for Windows users.
Actually, looking through it, most of it seems outdated, aimed at DOS/
ancient versions of Unix. I don't think I'll bother with it as a first
port of call, thanks very much.

Most of the FAQ is aimed at standard C, and it's an excellent
resource for that purpose. For system-specific questions, you
should use system-specific resources.
Answer to my original question still needed! Win32 console application.

If your question was so "urgent", perhaps you should have mentioned
the platform in the first place. The answers you got were perfectly
appropriate for the question you actually asked (which didn't
mention Windows or Win32).

Suggested reading: <http://www.catb.org/~esr/faqs/smart-questions.html>.
 
T

Tim Streater

Eric Sosman said:
It's surprising to learn that all those Windows implementations
of curses have disappeared. They used to roam the wide prairies in
their millions, shooting buffalo and eating passenger pigeons. But
now, you say, they've gone extinct while I wasn't looking. Sad.

Windows is going extinct? Best news I've heard in a coon's age.
 
K

Kenny McCormack

Eric Sosman said:
Fair enough. For my part, I won't answer next time you ask a
question that's in the FAQ.

And we'll all be happier for that. Thank you.
 
T

Tom St Denis

The cite only re-asks the question. The answer is that C does not give
the OP a way but certain control characters may have effects over and
above C that can color text. These can be entered with control
characters and may be documented in the reference manual for the OP's
printer. Alternatively, he may have to learn post-script or Rich Text
Format codes.

Strictly speaking the C spec doesn't guarantee that a console even
exist. In fact in many conforming platforms there isn't any TTY
interface whatsoever.
The whole philosophy of "FAQ" is micro-Fascism, since it pretends that
dialogue, of which questions are a part, is a waste of time. I for one
am sick to death of the attitude that understanding can be reified.

Which is ironic given your post contributed nothing to the dialogue
other than to state your childish distaste for process. *there there*
we've all heard you, now you can go sit down and be quiet for a
while. The adults are talking.
C is not old Basic in which various compiler-interpreters gave the
programmer the ability to draw crude colored pictures and tootle
monophonic songs. C, considered as a demiurge, does not care about the
color of characters.

That's about the only true thing in the post (I mean come on, you even
post under a pseudonym, so that's saying something).

Tom
 
S

spinoza1111

Strictly speaking the C spec doesn't guarantee that a console even
exist.  In fact in many conforming platforms there isn't any TTY
interface whatsoever.


Which is ironic given your post contributed nothing to the dialogue
other than to state your childish distaste for process.  *there there*
we've all heard you, now you can go sit down and be quiet for a
while.  The adults are talking.


That's about the only true thing in the post (I mean come on, you even
post under a pseudonym, so that's saying something).

I'd rephrase that. It's the only part you've understood.
 
S

spinoza1111

I will start by warning you that this question is asked a *lot* and is
therefore a signal that whoever is asking hasn't really done much research
to solve thre problem for themselves.  Most people don't like to
continually answer the same questions over and over again.  They wrote it
once and it usually doesn't take much to google for the answer.

There was no answer at the cite.

Every question, when asked, is a different question. To treat it as an
FAQ shows a weary contempt for humanity. Teachers and parents answer
"stupid" questions repeatedly as part of a conversation every day.

The reification (in which a concept is treated as a thing) in the
notion of FAQ is ultimately a form of victimization: one FAQ answer is
based on an incoherent document (C: the Complete Nonsense), written by
a person without qualifications which attempted to destroy a personal
reputation.

The purpose of the FAQ site is to show that unix, an OS developed in
1970, is still a viable model, especially in its modern rewrite,
linux, which was essentially stolen from the author of Minix.
 
T

Tom St Denis

I'd rephrase that. It's the only part you've understood.

It must be really convenient to live in world where you make up both
sides of conversations.

Tom
 
S

spinoza1111

It must be really convenient to live in world where you make up both
sides of conversations.

Well, "it's a dirty job, but someone's got to do it". I'm saying that
the process is wrong; if "maturity" means accepting rules which cannot
be questioned, then I'm glad to be "childish". The whole idea of FAQs
is a lazy way of sending newbies on their way at best. Here, the
administrative requirement is satisfied by an "answer" to the OP's
question which is not an answer at all.

It rests upon an illusion: that a "question" is always part of a
dialog with only one possible reply. It also omits the possibility
that the person is smarter than the collective administrative
apparatus, which is almost never true by way of the law of "least
common denominator".

Furthermore, like most administrative systems, that of the C FAQ
incorporates bias, here, in favor of unix and against "Windows" in a
way that fails to acknowledge the fact that "Windows", unlike unix,
has been more able to evolve BECAUSE it was such garbage in the past.

Windows 1.0 was a nightmare and a joke; we had great fun at Bell
Northern Research watching it stagger along trying to show us
"windows". Microsoft took the money from unsuspecting users with
enough 286 gear to make 1.0 run half acceptably and proceeded to
improve the product (that's called capitalism and even Marx would
approve). As a result, today's "Windows" incorporates lessons not
found in unix, which precisely because it was so great in 1970 has
failed to evolve, whether as unix, or as Linux. It's the phenomenon of
technical "leapfrog"...such as in China, whose rail system is vastly
superior to that of the US and which is on the verge of introducing
"Shanghai to London in two days by rail" within the next 20 years.

Linux and unix, no matter what release, are the same thing, whereas
Windows 7 is completely unlike Windows 3.1.

Worse, FAQs incorporate complete nonsense. Steve Summit's original FAQ
appears to have identified Schildt as "wrong on C" based on Seebach's
ridiculous tirade.

FAQs belittle people and trivialize things, like help desks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top