TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Larry Snider
from: David Noon
date: 1994-12-07 19:24:00
subject: C++ Character Fill

On Monday, 12-05-1994  Larry Snider wrote to All about "C++ CHARACTER
FILL" as follows:

LS> What I would like to do is just fill the screen with a particular
LS> character to give a textured look in the most efficient manner
LS> possible. In my case, ASCII 176.
LS> 
LS>  textcolor(WHITE);
LS>  textbackground(BLUE);
LS>  clrscr();
LS>     for (int j=1; j<=25; j++){
LS>         for (int i=1; i<=80; i++){
LS>             gotoxy(i,j);
LS>             cputs("X");
LS>             }
LS>         }

Hi Larry,

First off, you are establishing your position on the screen for every
character you display; the gotoxy() call is executed 2000 times. This
is at least 1975 times too many. [Hint, hint.]

Secondly, you are generating and processing a string for a single
character. A C/C++ string of length 1 is actually 2 bytes, so you are
processing twice as many bytes as necessary. Using cputs() to output a
single character is extremely inefficient. The putch() function is
more efficient when a single byte it being transmitted.

Also, be aware that these functions are specific (even _peculiar_) to
the Borland C/C++ compilers. Your code will not be transportable to
any other vendor's C/C++ implementation.

Regards

Dave

 * KWQ/2 1.2g * PL/I: Understatement is the purest form of eloquence.
--- Maximus/2 2.02

* Origin: OS/2 Shareware BBS, Fairfax, VA: 703-385-4325 (1:109/347)
SEEN-BY: 12/2442 54/54 620/243 624/50 632/348 640/820 690/660 711/409 410 413
SEEN-BY: 711/430 807 808 809 934 942 949 712/353 623 713/888 800/1
@PATH: 109/347 2 7 3615/50 229/2 12/2442 711/409 54/54 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.