Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


hmm..why doesn't this work?

This topic is 6110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

#include #include int main() { textcolor(RED); cout<<"shit!....."; getch(); return 0; } OR #include #include int main() { textcolor(RED); printf ("DOH!"); getch(); return 0; } and what exactly does printf do??

Share this post

Link to post
Share on other sites
Just a few things.

setcolor() doesn''t affect on cout so you can''t use it.

setcolor() doesn''t affect on printf() so you can''t use it either.
(and printf is just a function to print some text)

And if you want your colored text, you use cprintf() function.

Share this post

Link to post
Share on other sites
what does not work?

oh, and what printf does is simple.. take a look at sprintf

sprintf takes a destination-buffer,a inputbuffer and extraparameters.

now for what? the inputbuffer is a string with a specific format, means with stuff like %i or %s or %f in, and in the extraparameters you can replace the %i ... stuff with those values. printed is the resulting string in the destination-buffer.


char output[256];
char input[] = "The Value of My Integer: %i\n";
int my_integer = 10;

now output is "The Value of My Integer: 10\n"; with \n representing a new-line

means putting this onto screen results in this:

The Value of My Integer: 10


now what does printf do? the same, except it prints the formated text not in a user-defined buffer (here ''output'') but on the screen (-buffer.. yeah, its a buffer itself, the screen).

thats it..

printf("Print out value of an int:%i or of a float:%f or another text %s or a letter %c\n\n",an_int,a_float,a_text);

if you have this code:

printf("Hello World\n");
Hello World


hope this helped a little.. for all those %i %f etc and the \n \b \t etc please look in some helpfiles or such stuff.. msdn-library is a huge resource for example

we wanna play, not watch the pictures

Share this post

Link to post
Share on other sites
thx alot =)

but do you think you can modify my code above so it can actually output colored letters and a colored background?

and do any of you know how to change the program so it runs on a windows interface window instead of DOS?

Share this post

Link to post
Share on other sites
You can use this to change the background color:

For letters, you simply do this: cprintf("a");

And you need only "<"conio.h">" in your project.

Edited by - MindFlayer on December 31, 2001 9:51:57 AM

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!