surviving the clrscr()

Hello c++.com The Names Raza .I am A begginer In C++. I am making a periodic table for leisure but i have a problem I want it to be a bit fancy and hence i have made ASCII periodic table but I want It TO stay even after encountering a clrscr()
so here is the output of the program.



//////////////////////////This Should Stay/////////////////////////////////////
    1                                                                      18  
   1A                                                                      8B  
  ----- 2                                             13  14  15  16  17  -----
1 | H | 2A                                            3B  4B  5B  6B  7B  |He |
  |---+----                                           --------------------+---|
2 |Li |Be |                                           | B | C | N | O | F |Ne |
  |---+---|    3   4   5   6   7   8   9   10  11  12 |---+---+---+---+---+---|
3 |Na |Mg |    3B  4B  5B  6B  7B |    8B     |1B  2B |Al |Si | P | S |Cl |Ar |
  |---+---|   |---------------------------------------+---+---+---+---+---+---|
4 |K  |Ca |   |Sc |Ti |V  |Cr |Mn |Fe |Co |Ni |Cu |Zn |Ga |Ge |As |Se |Br |Kr |
  |---+---|   |---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---|
5 |Rb |Sr |   | Y |Zr |Nb |Mo |Tc |Ru |Rh |Pd |Ag |Cd |In |Sn |Sb |Te | I |Xe |
  |---+---|   |---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---|
6 |Cs |Ba |LAN|Lu |Hf |Ta | W |Re |Os |Ir |Pt |Au |Hg |Ti |Pb |Bi |Po |At |Rn |
  |---+---|   |---+---+---+---+---+---+---+---+---+---+---+--+---+---+---+----|
7 |Fr |Ra |ACT|Lr |Rf |Db |Sg |Bh |Hs |Mt |Ds |Rg |Cn |Uut|Fl |Uup|Lv |Uus|Uuo|
  ---------   -----------------------------------------------------------------
                                                                               
              -------------------------------------------------------------    
   Lanthanide |La |Ce |Pr |Nd |Pm |Sm |Eu |Gd |Tb |Dy |Ho |Er |Tm |Yb |Lu |    
              |---+---+---+---+---+---+---+---+---+---+---+---+---+---+---|    
   Actinide   |Ac |Th |Pa | U |Np |Pu |Am |Cm |Bk |Cf |Es |Fm |Md |No |Lw |    
              -------------------------------------------------------------    

//////////////////////////This Should Stay ///////////////////////////////////// 

Welcome User The Following Program Will Help You Find All The Information You
Need About Any element In The Periodic Table
clrscr()
You Can Search The Program Using Any Of The Following Methords: 
1.By Symbol.
2.By Name
3.By Atomic Number
Which Way Would You Prefer: 
cin>>choice
Then The Three Options Will Execute
clrscr()
nElement Name: 
Element Symbol:
Atomic Number: 
Atomic Mass: 
State At Room Temperature: 
Found In Group: 
Melting Point: 
Boiling Point:  C
Density (g/cm^3): 
Ionisation Enthalpy(eV): 
clrscr()
clrscr()


As You Can See The Table Has To Survive 4-5 clrscr() Soo My Dear Society Of Programmers Please Help Me
Last edited on
Try something like ncurses (http://www.gnu.org/software/ncurses/) to allow you to manipulate the terminal better.

I was looking around ans saw http://utio.sourceforge.net/ but only glanced at it. Take a look.


A
The first link doesn't work and the second is like a wall of text

could you explain about
ncurses
and how to use them in borland C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <cstdlib>

void new_clrscr()
{
    std::system( "cls" ) ; // or clrscr() or whatever required to clear the screen

    std::cout <<
        "///////////////////////////////////////////////////////////////////////////////\n"
        "    1                                                                      18  \n"
        "   1A                                                                      8B  \n"
        "  ----- 2                                             13  14  15  16  17  -----\n"
        "1 | H | 2A                                            3B  4B  5B  6B  7B  |He |\n"
        "  |---+----                                           --------------------+---|\n"
        "2 |Li |Be |                                           | B | C | N | O | F |Ne |\n"
        "  |---+---|    3   4   5   6   7   8   9   10  11  12 |---+---+---+---+---+---|\n"
        "3 |Na |Mg |    3B  4B  5B  6B  7B |    8B     |1B  2B |Al |Si | P | S |Cl |Ar |\n"
        "  |---+---|   |---------------------------------------+---+---+---+---+---+---|\n"
        "4 |K  |Ca |   |Sc |Ti |V  |Cr |Mn |Fe |Co |Ni |Cu |Zn |Ga |Ge |As |Se |Br |Kr |\n"
        "  |---+---|   |---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---|\n"
        "5 |Rb |Sr |   | Y |Zr |Nb |Mo |Tc |Ru |Rh |Pd |Ag |Cd |In |Sn |Sb |Te | I |Xe |\n"
        "  |---+---|   |---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---|\n"
        "6 |Cs |Ba |LAN|Lu |Hf |Ta | W |Re |Os |Ir |Pt |Au |Hg |Ti |Pb |Bi |Po |At |Rn |\n"
        "  |---+---|   |---+---+---+---+---+---+---+---+---+---+---+--+---+---+---+----|\n"
        "7 |Fr |Ra |ACT|Lr |Rf |Db |Sg |Bh |Hs |Mt |Ds |Rg |Cn |Uut|Fl |Uup|Lv |Uus|Uuo|\n"
        "  ---------   -----------------------------------------------------------------\n"
        "                                                                               \n"
        "              -------------------------------------------------------------    \n"
        "   Lanthanide |La |Ce |Pr |Nd |Pm |Sm |Eu |Gd |Tb |Dy |Ho |Er |Tm |Yb |Lu |    \n"
        "              |---+---+---+---+---+---+---+---+---+---+---+---+---+---+---|    \n"
        "   Actinide   |Ac |Th |Pa | U |Np |Pu |Am |Cm |Bk |Cf |Es |Fm |Md |No |Lw |    \n"
        "              -------------------------------------------------------------    \n"
        "                                                                               \n"
        "///////////////////////////////////////////////////////////////////////////////\n" ;
}

#define clrscr() new_clrscr()

int main()
{
    clrscr() ;
    std::cout << "program to test clrscr()\n" ;

    for( int i = 2 ; i < 7 ; ++i )
    {
        char ch ;
        std::cout << "please enter a letter and then press enter to print something: " ;
        std::cin >> ch ;

        for( int j = 0 ; j < i ; ++j ) std::cout << i << '.' << j << ". hello word\n" ;

        std::cout << "please enter a letter and then press enter to clear the screen: " ;
        std::cin >> ch ;
        clrscr() ;
    }
}
Last edited on
Thankyou My Program Runs Perfectly Now
Good to hear that you got it working. Strange that the link didn't work. If you ever want to check it out just google it.

Is new_clrscr() a Borland extension?
You you are going to post a link in parenteses, remember to leave space between last link character and closing parentesis, or it will be added to link, ruining it.

If you read code, you'll see that new_clrscr() if a user-defined function
MiiNiPaa, funny, I didn't see that it was a function. Cute. :)

Thanks for the heads up on the parenthesis thing. That's not happened on other sites I've been on.
Topic archived. No new replies allowed.