Thread: [Dev-C++] Setting text colour
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Dany P. W. <da...@qu...> - 2003-04-12 09:06:00
|
Hi everyone, I'm just writing console programs at the moment, and was wondering if there's a way of setting foreground and background colour of text? Is this possible using standard C++ libraries? Cheers, Dany. -- This mail is a natural product. The slight variations in spelling and grammar enhance its individual character and beauty and in no way are to be considered flaws or defects. |
|
From: Per W. <pw...@ia...> - 2003-04-12 09:33:43
|
No, it's not possible with 'standard' C++ libraries. To be able to set foreground and background colour, you must first decide what target system you are aiming for, and then locate some suitable functions. While it is possible to use escape sequences for setting colour on MSDos/Win32 command lines, most code either draws directly to the text memory, or calls bios functions. On Unix machines in general, most programs usess escape sequences, since the program may not run on IBM PC-compatible hardware, thereby not having a PC bios or a PC-compatible text display. /Per W On Sat, 12 Apr 2003, Dany P. Wu wrote: > Hi everyone, > > I'm just writing console programs at the moment, and was wondering if > there's a way of setting foreground and background colour of text? Is > this possible using standard C++ libraries? > > > Cheers, > Dany. > > -- > This mail is a natural product. The slight variations in > spelling and grammar enhance its individual character and > beauty and in no way are to be considered flaws or defects. > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger > for complex code. Debugging C/C++ programs can leave you feeling lost and > disoriented. TotalView can help you find your way. Available on major UNIX > and Linux platforms. Try it free. www.etnus.com > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Ioannis V. <iv...@at...> - 2003-04-12 11:18:36
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Per Westermark > Sent: Saturday, April 12, 2003 12:32 PM > To: Dany P. Wu > Cc: dev...@li... > Subject: Re: [Dev-C++] Setting text colour > > > No, it's not possible with 'standard' C++ libraries. > > To be able to set foreground and background colour, you must > first decide > what target system you are aiming for, and then locate some suitable > functions. > > While it is possible to use escape sequences for setting colour on > MSDos/Win32 command lines, most code either draws directly to the text > memory, or calls bios functions. > > On Unix machines in general, most programs usess escape > sequences, since > the program may not run on IBM PC-compatible hardware, > thereby not having > a PC bios or a PC-compatible text display. I remember ANSI graphics from the old times (we had to include ansi.sys for them to work). I am assuming ANSI graphics are not valid anymore in the Win2k/WinXP world but if someone has a DOS system he can do the job (or maybe even Win9x). They worked also with escape sequences even in a batch file. But he probavly would be satsfied with Allegro library. Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net Anti-racism movement: http://www.positive-youthfoundation.org Iraq Peace Pledge: http://www.peacepledge.org |
|
From: iad929 <ia...@jo...> - 2003-04-12 12:28:05
|
> I'm just writing console programs at the moment, and was wondering if > there's a way of setting foreground and background colour of text? Is > this possible using standard C++ libraries? In standard C++ you can't do this. Standard C++ aims to portability and hence avoids dealing with console colors because this differs from computer to computer. You need to specify what type of computer you're using and which OS and which vcompiler you use. N.B. Your Reply-To is set. Please uncheck it. Mohammed |
|
From: nada <na...@ca...> - 2003-04-12 13:19:53
|
I'm interested in the opinions of the group.
Is there anything in the C++ language which you feel inherently can
contribute to new programmers developing bad programming habits? Is C++ an
inappropriate language for an introductory course, a course that is
designed to introduce learners to programming concepts, not necessarily
prepare them for a programming career?
Thanks for your comments.
{rb}
|
|
From: iad929 <ia...@jo...> - 2003-04-12 14:01:31
|
> Is there anything in the C++ language which you feel inherently can > contribute to new programmers developing bad programming habits? Is C++ an > inappropriate language for an introductory course, a course that is > designed to introduce learners to programming concepts, not necessarily > prepare them for a programming career? > C++ is an excellent language for such a topic. But students must know about OOP. Mohammed |
|
From: Ioannis V. <iv...@at...> - 2003-04-12 14:08:03
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf Of nada
> Sent: Saturday, April 12, 2003 4:20 PM
> To: dev...@li...
> Subject: [Dev-C++] [q] Does C++ promote bad programming?
>
>
> I'm interested in the opinions of the group.
>
> Is there anything in the C++ language which you feel inherently can
> contribute to new programmers developing bad programming
> habits? Is C++ an
A programming language can't protect you from bad programming(!). For
example one may have the bad habbit to do:
template<class T>
T add(T a, T b)
{
T c1=a, T c2=b;
while(c1/a<2 && c2/b<2)
c1++, c2++;
return a+b;
}
int main()
{
int x=1, y=2;
int z=add(x,y);
}
> inappropriate language for an introductory course, a course that is
> designed to introduce learners to programming concepts, not
> necessarily
> prepare them for a programming career?
In the contrary. C++ supports 4 paradigms and each one *well* and with
optimal space/time efficiency. For example, in the OO paradigm it supports
multiple inheritance. Few other languages do that (personally I do not know
any other but I assume there is).
So for example if you want to teach all the concepts of Object Oriented
programming, C++ is a perfect candidate.
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
Anti-racism movement: http://www.positive-youthfoundation.org
Iraq Peace Pledge: http://www.peacepledge.org
|
|
From: Zodiaq <zo...@ac...> - 2003-04-12 14:36:43
|
Hello Ioannis and all Dev-C++ users, Saturday, April 12, 2003, 4:07:54 PM, Ioannis wrote as follows: IV> So for example if you want to teach all the concepts of Object Oriented IV> programming, C++ is a perfect candidate. IMHO for such course better is Java - it has all benefits of OOP but whithout pointers and with garbage collector and tables boundary checking - which (for beginners) is very important... IMHO learning C++ (as a faster language) should be done AFTER Java course... -- regards, Zodiaq |
|
From: Ioannis V. <iv...@at...> - 2003-04-12 15:09:45
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf Of Zodiaq > Sent: Saturday, April 12, 2003 5:36 PM > To: Dev...@li... > Subject: Re[2]: [Dev-C++] [q] Does C++ promote bad programming? > > > Hello Ioannis and all Dev-C++ users, > > Saturday, April 12, 2003, 4:07:54 PM, Ioannis wrote as follows: > > IV> So for example if you want to teach all the concepts of > Object Oriented > IV> programming, C++ is a perfect candidate. > > IMHO for such course better is Java - it has all benefits of OOP but > whithout pointers and with garbage collector and tables boundary > checking - which (for beginners) is very important... IMHO learning > C++ (as a faster language) should be done AFTER Java course... Java uses pointers although it is somewhat transparent to the user. You are not forced to use pointers in C++. You use them if you want them. Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net Anti-racism movement: http://www.positive-youthfoundation.org Iraq Peace Pledge: http://www.peacepledge.org |
|
From: Per W. <pw...@ia...> - 2003-04-12 18:44:55
|
It is very, very tough to write a C or C++ program without any pointers. Try writing a hello world program :-) I was about to supply one in this mail, when I realized that I couldn't even get past main() without adding a pointer to any command line arguments... /Per W On Sat, 12 Apr 2003, Ioannis Vranos wrote: > > -----Original Message----- > > From: dev...@li... > > [mailto:dev...@li...] On Behalf Of Zodiaq > > Sent: Saturday, April 12, 2003 5:36 PM > > To: Dev...@li... > > Subject: Re[2]: [Dev-C++] [q] Does C++ promote bad programming? > > > > > > Hello Ioannis and all Dev-C++ users, > > > > Saturday, April 12, 2003, 4:07:54 PM, Ioannis wrote as follows: > > > > IV> So for example if you want to teach all the concepts of > > Object Oriented > > IV> programming, C++ is a perfect candidate. > > > > IMHO for such course better is Java - it has all benefits of OOP but > > whithout pointers and with garbage collector and tables boundary > > checking - which (for beginners) is very important... IMHO learning > > C++ (as a faster language) should be done AFTER Java course... > > > Java uses pointers although it is somewhat transparent to the user. > > > You are not forced to use pointers in C++. You use them if you want them. > > > > > Ioannis Vranos > > * Programming pages: http://www.noicys.freeurl.com > * Alternative URL 1: http://run.to/noicys > * Alternative URL 2: http://www.noicys.cjb.net > > > Anti-racism movement: http://www.positive-youthfoundation.org > Iraq Peace Pledge: http://www.peacepledge.org > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger > for complex code. Debugging C/C++ programs can leave you feeling lost and > disoriented. TotalView can help you find your way. Available on major UNIX > and Linux platforms. Try it free. www.etnus.com > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Ioannis V. <iv...@at...> - 2003-04-12 19:06:22
|
> -----Original Message----- > From: Per Westermark [mailto:pw...@ia...] > Sent: Saturday, April 12, 2003 9:42 PM > To: Ioannis Vranos > Cc: Dev...@li... > Subject: RE: Re[2]: [Dev-C++] [q] Does C++ promote bad programming? > > > It is very, very tough to write a C or C++ program without > any pointers. > > Try writing a hello world program :-) > > I was about to supply one in this mail, when I realized that > I couldn't > even get past main() without adding a pointer to any command line > arguments... In that sense, in all programming languages there is no way to avoid pointers. Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net Anti-racism movement: http://www.positive-youthfoundation.org Iraq Peace Pledge: http://www.peacepledge.org |
|
From: jose i. c. <ji...@fr...> - 2003-04-12 19:15:17
|
From: "Ioannis Vranos" <iv...@at...> said, > > IMHO for such course better is Java - it has all benefits of OOP but > > whithout pointers and with garbage collector and tables boundary > > checking - which (for beginners) is very important... IMHO learning > > C++ (as a faster language) should be done AFTER Java course... > > > Java uses pointers although it is somewhat transparent to the user. > > > You are not forced to use pointers in C++. You use them if you want them. Let's not forget the real reason why we use c/c++: speed. :-) It's not for its easy way of coding programs. So, why wouldn't you use pointer if you're using c/c++? jose |
|
From: Ioannis V. <iv...@at...> - 2003-04-12 19:35:09
|
> -----Original Message----- > From: jose isaias cabrera [mailto:ji...@fr...]=20 > Sent: Saturday, April 12, 2003 10:15 PM > To: Ioannis Vranos; Dev...@li... > Subject: Re: Re[2]: [Dev-C++] [q] Does C++ promote bad programming? >=20 >=20 >=20 >=20 > From: "Ioannis Vranos" <iv...@at...> said, >=20 > > > IMHO for such course better is Java - it has all benefits=20 > of OOP but > > > whithout pointers and with garbage collector and tables boundary > > > checking - which (for beginners) is very important...=20 > IMHO learning > > > C++ (as a faster language) should be done AFTER Java course... > > > > > > Java uses pointers although it is somewhat transparent to the user. > > > > > > You are not forced to use pointers in C++. You use them if=20 > you want them. >=20 > Let's not forget the real reason why we use c/c++: speed. :-)=20 Not only. I use it also because it is the best general purpose = programming language. :) > It's not for > its easy way of coding programs. So, why wouldn't you use=20 > pointer if you're > using c/c++? I did not say we should not use pointers. Of course we should where it = makes sense. I just answered to the claims that in Java it is easier or safer = to do things than in C++. Because it isn't. C++ implements all the = supported paradigms well. The main misconception many people have regarding C++, is that it is = unsafe because they use its low level parts when it is entirely unnecessary. Another crucial misconception is that many peope think programming is = easy and find facilities which exist to enable certain things as "difficult", missing the techniques that they exist to support. A very useful URL for that is: http://www.itworld.com/AppDev/710/lw-02-stroustrup/page_1.html Ioannis Vranos =20 * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net Anti-racism movement: http://www.positive-youthfoundation.org Iraq Peace Pledge: http://www.peacepledge.org |
|
From: iad929 <ia...@jo...> - 2003-04-12 15:10:32
|
> IMHO for such course better is Java - it has all benefits of OOP but > whithout pointers and with garbage collector and tables boundary > checking - which (for beginners) is very important... IMHO learning > C++ (as a faster language) should be done AFTER Java course... > I little disagree with you here. C++ can be used for an introductory course with avoiding pointers. Java is simple but it is web directed. Mohammed |
|
From: Zodiaq <zo...@ac...> - 2003-04-12 17:45:46
|
Hello iad929 and all Dev-C++ users, Saturday, April 5, 2003, 11:18:48 PM, iad929 wrote as follows: i> I little disagree with you here. C++ can be used for an introductory course i> with avoiding pointers. Java is simple but it is web directed. Avoiding pointers with C++ is hard thing, without dynamic storage and dynamic object generation (long lasting) programs are not so interesting... and what is more important C++ is hard becouse it mades not boundary checking - it's because it aims for speed... and using std::vector at an introductory course is neither good thing... at very beginning you might be foced to answer what is std, namespace, vector, template etc... this is all very confusing at the begining, and without that people have many problems with programs in C++/C crushing because some memory was written where it shouldn't - Java at first such attempt stops! Which, for beginners to OOP is very important! This forces good habbits as cerufully checking where last iterations of loops will be writing to and many others... I'm talking here from my point of view - my road to OOP was like this: Basic (not even on PC class) C C++ and Java (at studies teachers somehow decided to combine these two) and now I stick to C++ (with every aspect it offers - OOP, exceptions, multithreading [this is more OS dependent, I know]) but I must say that (for me) learning Java was a very good thing - at the time I thought I shouldn't be doing that! I thought on high level programming language is more than enough! But from this point of view, from current time, I must say it was very usefull experience... All right, stop chatting, last thing - Java is not JUST simple, it also makes things simple... it is not only web directed, you can make web applets in it very easly, but you can make programs that have NOTHING to do with web... I don't use it because it is interpreted so not nearly as fast as C++... Java is good for small programs that have to be run on many platforms, but for big projects that need to be very fast... That's what I thing - IMO Java is very good start... i> Mohammed -- regards, Zodiaq |
|
From: Ioannis V. <iv...@at...> - 2003-04-12 19:04:45
|
> -----Original Message----- > From: dev...@li...=20 > [mailto:dev...@li...] On Behalf Of Zodiaq > Sent: Saturday, April 12, 2003 8:45 PM > To: Dev...@li... > Subject: Re[4]: [Dev-C++] [q] Does C++ promote bad programming? >=20 >=20 >=20 > Avoiding pointers with C++ is hard thing, without dynamic storage and > dynamic object generation (long lasting) programs are not so > interesting... Java on the other hand uses pointers only. > and what is more important C++ is hard becouse it mades > not boundary checking ? > - it's because it aims for speed... and using > std::vector at an introductory course is neither good thing... at very > beginning you might be foced to answer what is std, namespace, vector, > template etc... this is all very confusing at the begining, and > without that people have many problems with programs in C++/C crushing > because some memory was written where it shouldn't No, you seem to miss all the safety C++ provides. If you want range = checked access to vector you can use vector::at(). With C++ very safe, = bullef-proof code can be written, simply by using the standard library facilities and avoiding the use of low level stuff, direct memory = allocation/deallocation, casts, macros, void *s. > - Java at first > such attempt stops! :) Java merely is a subset of C++ possibilites. Which is not necessarily bad. > Which, for beginners to OOP is very important! In C++ one can learn whatever he needs to learn.=20 > This forces good habbits as cerufully checking where last iterations > of loops will be writing to and many others... I'm talking here from > my point of view - my road to OOP was like this: > Basic (not even on PC class) > C > C++ and Java (at studies teachers somehow decided to combine=20 > these two) >=20 > and now I stick to C++ (with every aspect it offers - OOP, exceptions, > multithreading [this is more OS dependent, I know]) but I must say > that (for me) learning Java was a very good thing - at the time I > thought I shouldn't be doing that! I thought on high level programming > language is more than enough! But from this point of view, from > current time, I must say it was very usefull experience... All right, > stop chatting, last thing - Java is not JUST simple, it also makes > things simple... it is not only web directed, you can make web applets > in it very easly, but you can make programs that have NOTHING to do > with web... I don't use it because it is interpreted so not nearly as > fast as C++... Java is good for small programs that have to be run on > many platforms, but for big projects that need to be very fast... Myself I do not like Java (I am using the most soft words). There are = many reasons, but I do not want to begin a flame now. :) An interesting URL = to check is: http://www.stlport.org/resources/StepanovUSA.html >=20 > That's what I thing - IMO Java is very good start... On the other hand I believe it is one of the worst (knowing at the same = time that there are many that disagree with me). Ioannis Vranos =20 * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net Anti-racism movement: http://www.positive-youthfoundation.org Iraq Peace Pledge: http://www.peacepledge.org |
|
From: iad929 <ia...@jo...> - 2003-04-12 15:12:16
|
> In the contrary. C++ supports 4 paradigms and each one *well* and with > optimal space/time efficiency. For What do you mean by 4 paradigms? Mohammed |
|
From: Ioannis V. <iv...@at...> - 2003-04-12 15:18:16
|
> -----Original Message----- > From: iad929 [mailto:ia...@jo...] > Sent: Sunday, April 06, 2003 12:21 AM > To: Ioannis Vranos; dev...@li... > Subject: Re: [Dev-C++] [q] Does C++ promote bad programming? > > > > In the contrary. C++ supports 4 paradigms and each one > *well* and with > > optimal space/time efficiency. For > > What do you mean by 4 paradigms? C++ supports 4 paradigms: - Procedural paradigm (functions) - Modular paradigm (namespaces) - Object Oriented paradigm - Generic programming paradigm (templates) Each paradigm is supported well (completely) with optimal space/time efficiency. Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net Anti-racism movement: http://www.positive-youthfoundation.org Iraq Peace Pledge: http://www.peacepledge.org |