Clear Screen function in C++

Mark Papadakis markp at pathfinder.gr
Fri Sep 10 23:48:08 EEST 1999


Lipon,

Basically
to noecho() leei oti oi oti grafeis den gineted output stin othoni su. allakse to noecho() me to echo() kai tha tus deis..


Tora gia to allo
Den exeis katalavei kati.
me curses den kaneis character output me cout <<, alla me curses functions, opws printw();
i printw() einai i printf() me tin diafora oti einai curses based.. 
dokimase tin kai tha deis oti tha dulepsei.

gia perissotera 
man curs_printw

Ante good luck,
MarkP at PhaistosNetworks.gr
Apostolis Rudis wrote:
>
>On Wed, 8 Sep 1999 21:47:10 +0300
>"Mark Papadakis" <markp at pathfinder.gr> wrote:
>
>> ncurses einai mia lisi, iparxun kai alles. As pume oti to kaneis
>me ncurses..
>> des to paradeigma:
>> 
>> #include <curses.h>
>
>... deleted ...
>
>Παραθέτω τον κώδικα που έχω γράψει, έτσι όπως τροποποιήθηκε με τα
>καινούρια στοιχεία της curses.h
>
>//File Name: 5.cpp
>//Author: Apostolis Rountis
>//Email Address: apostolis at mail.com
>//Description: Nested ifs and elses along with a few while loops ...
>//Last changed: September 10, 1999
>
>#include <iostream.h>
>#include <curses.h>
>
>int main()
>{
>                                                    
>//printf("\033[H\033[J");
>
>initscr(); cbreak(); noecho();
>nonl();
>intrflush(stdscr, FALSE);
>keypad(stdscr, TRUE);
>clear();
>refresh();
>
>    long int koko, lala, lili;
>    cout << "\nThis program demostrates the nested if and
>else statements.\n";
>    cout << "\nIt also handles positive as much as
>negative numbers.\n";
>    cout << "\nTry every possible combination, including
>the case of\n";
>    cout << "incerting the same correct number twice, and
>see what
>happens!\n";
>    cout << "\nTry to also place the numbers 10, -10, 20
>and -20 instead
>of\n";
>    cout << "other values, to see the loop.\n";
>
>    cout << "\nAll right, gimme a number larger than 10 or
>smaller than -10:
>";
>    cin >> koko;
>
>    while ((koko == 10) || (koko == -10))
>    {
>    cout << "\nI said larger than 10 or smaller than
>-10!\n";
>    cout << "That means, 10 and -10 are not included! Are
>you blind,"
>         << " or what?\n";
>    cout << "Try again: ";
>    cin >> koko;
>    }
>    if ((koko > 10) || (koko < -10))
>    {
>    {
>    cout << "\nThank you."
>         << "\nNow gimme another one larger than 20 or
>smaller than -20: ";
>    cin >> lala;
>    while ((lala == 20) || (lala == -20))
>    {
>    cout << "\nAh, you are a complete idiot!\n"
>         << "I said larger than 20 or smaller than -20!
>Can't you read?\n";
>    cout << "Try again: ";
>    cin >> lala;
>    }
>    lili = (koko + lala);
>    }
>        if ((lala > 20) || (lala < -20))
>	{
>	    if (koko == lala)
>	    {
>	    cout << "\nExcellent! The sum of your numbers is:
>" << lili << "\n";
>	    cout << "You placed the same number twice, eh? I got
>ya!!!\n\n";
>	    }
>	    else
>	    cout << "\nGreat! The sum of your numbers is: "
><< lili << "\n\n";
>	}
>	else
>        {
>	cout << "\nThe number you entered is smaller than
>20!!!" << endl;
>        cout << "Are you trying to cheat here? Rerun the
>program!\n" << endl;
>
>        }
>    }
>    else
>    {
>    cout << "\nThe number you entered is smaller than
>10!!!" << endl;
>    cout << "Are you trying to cheat here? Rerun the
>program!\n" << endl;    
>    }
>
>keypad(stdscr, FALSE);
>endwin();
>
>    return 0;
>}   
>
>Η εντολή που έδωσα για το compiling ήταν g++ koko.cpp -o koko
>-lncurses
>
>Τώρα ναι μεν λειτουργεί το clear screen αλλά οι γραμμές του μηνύματος
>που βγαίνουν πριν ζητηθεί ο πρώτος αριθμός είναι λες και κάποιος
>πάτησε
>μερικά tabs σε κάθε γραμμή... Επίσης δε βλέπω τον αριθμό που εισάγω!
>
>Αν βάλεις // σε όλες τις εντολές που αφορούν την curses και αφήσεις
>μόνο
>την παράξενη εντολή printf("\033[H\033[J"); θα παρατηρήσεις
>ότι τα
>πράγματα είναι πολύ καλύτερα. Το κείμενο εμφανίζεται κανονικά και ο
>αριθμός που εισάγεις είναι ορατός.
>
>Παρά το γεγονός ότι πειραματίστηκα πολύ με την curses, δεν κατάφερα
>να
>μου δείχνει αυτά που βλέπω με την printf...
>
>
>         Apostolis
>apostolis at mail.com
>--
>====================================================================
>Gia boithia (h na diagrafhte) e-mail sto majordomo at hellug.gr
>Ta archives tis listas einai sto http://lists.hellug.gr/archives
>prin steilete kapoia erothsh psakte mipos exei hdh apanththei.
>Gia opoiodipote problima stilte e-mail ston
>owner-linux-greek-users at hellug.gr
>====================================================================

--
====================================================================
Gia boithia (h na diagrafhte) e-mail sto majordomo at hellug.gr
Ta archives tis listas einai sto http://lists.hellug.gr/archives
prin steilete kapoia erothsh psakte mipos exei hdh apanththei.
Gia opoiodipote problima stilte e-mail ston owner-linux-greek-users at hellug.gr
====================================================================



More information about the Linux-greek-users mailing list