Hi, i'm new on this forum.
My simple and only questions is:
Can I crate a color printf (cprintf on turbo C) on dev c++?
tks ^^
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2005-11-21
The MSDN link posted right after the "WriteConsoleOutput" post IS the documentation for WriteConsoleOutput(), so not much searching required!
I beleive that the 'c' in cprintf() stands for "console" not "color". It outputs direct to the console in DOS based systems, whereas printf() may be redirected to any stream io device.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am running Dev version 4.9.9.2 on XP Pro, the code (cut and paste job, no alterations) is
// color your text in Windows console mode
// colors are 0=black 1=blue 2=green and so on to 15=white
// colorattribute = foreground + background * 16
// to get red text on yellow use 4 + 1416 = 228
// light red on yellow would be 12 + 1416 = 236
// a Dev-C++ tested console application by vegaseat 07nov2004
include <iostream>
include <windows.h> // WinApi header
using namespace std; // std::cout, std::cin
int main()
{
HANDLE hConsole;
int k;
hConsole=GetStdHandle(STD_OUTPUT_HANDLE);// you can loop k higher to see more color choicesfor(k=1;k<255;k++){// pick the colorattribute k you wantSetConsoleTextAttribute(hConsole,k);cout<<k<<"Iwanttobenicetoday!"<<endl;}cin.get();// waitreturn0;
The mayor error is this: "iostream: No such file or directory."
The point is, i have the iostream on the header past, so why won't compile?
PS:My version is 4.9.8
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When someone gives you a keyword, and you don't know what it is, you first stop should be google (or your favorite search engine), not posting back and asking what the term is.
I am not trying to be mean, simply pointing out the power of trying to learn things on your own.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
...you don't have to know everything, the only thing everybody should really be able to do is RESEARCH, the internet makes this extremely simple nowadays, so use the tools at your hands to your advantage.
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, i'm new on this forum.
My simple and only questions is:
Can I crate a color printf (cprintf on turbo C) on dev c++?
tks ^^
The MSDN link posted right after the "WriteConsoleOutput" post IS the documentation for WriteConsoleOutput(), so not much searching required!
I beleive that the 'c' in cprintf() stands for "console" not "color". It outputs direct to the console in DOS based systems, whereas printf() may be redirected to any stream io device.
Clifford
well....maybe my I.E cant open the page, but the MSDN link wont open here(I tested on firefox too)
The link I posted still works, and the code does as well....I tested it before I told you about it.
;)
Wayne
that's irony,for quite some time MSDN pages contained extra code so that they would only be properly displayed in IE :-)
Humm ok guys, I'll read somethings here
by the way, this example http://www.daniweb.com/code/showsnippet.php?codeid=83 , it won't work on Dev C++.
tks ^^
Actually, as I stated earlier, it does work.
I always compile and run such examples before I post a link to it.
What problem did you run into?
Wayne
My Basic 3
I am running Dev version 4.9.9.2 on XP Pro, the code (cut and paste job, no alterations) is
// color your text in Windows console mode
// colors are 0=black 1=blue 2=green and so on to 15=white
// colorattribute = foreground + background * 16
// to get red text on yellow use 4 + 1416 = 228
// light red on yellow would be 12 + 1416 = 236
// a Dev-C++ tested console application by vegaseat 07nov2004
include <iostream>
include <windows.h> // WinApi header
using namespace std; // std::cout, std::cin
int main()
{
HANDLE hConsole;
int k;
}
Here is my log:
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\mycstuff\testit.cpp" -o "C:\mycstuff\testit.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
Execution terminated
Compilation successful
And it changes foreground and background colors as expected when run.
Note that this is C++ code, if you name it something.c, it will try to compile as C code, and that will not work.
Wayne
The mayor error is this: "iostream: No such file or directory."
The point is, i have the iostream on the header past, so why won't compile?
PS:My version is 4.9.8
There was a reason why I posted MY basic 3. ;)
Please post yours - see the thread titled "Please Read Before Posting a Question" if you are unsure what they are.
Wayne
"WriteConsoleOutput"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/conchar_9ktw.asp
not devc++ specific, but win32 specific.
What do you mean whit "WriteConsoleOutput"
give me some examples please ^^
tks
When someone gives you a keyword, and you don't know what it is, you first stop should be google (or your favorite search engine), not posting back and asking what the term is.
I am not trying to be mean, simply pointing out the power of trying to learn things on your own.
Wayne
...you don't have to know everything, the only thing everybody should really be able to do is RESEARCH, the internet makes this extremely simple nowadays, so use the tools at your hands to your advantage.
Mike
This is an example you might find intersting to play with:
http://www.daniweb.com/code/showsnippet.php?codeid=83
(It works for printf too)
Wayne
Try this: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/console_reference.asp
All you had to do was click up-one-level on the side bar, or even select "WriteConsoleOutput" from the sidebar to get there directly.
The URL appears to be correct, but MSDN seems to be blocking a direct link to it.
Clifford