#include<ncurses.h>
int main()
{
        WINDOW *win ;
        initscr();
        win = newwin(10,30,10,10);
        box( win, ACS_VLINE, ACS_HLINE);
        refresh();
        wrefresh(win);
        mvwprintw(win , 13, 14, "Enter any Key :\n ");
        refresh();
        wrefresh(win);
        getch();
        refresh();
        wrefresh(win);
        endwin();
        printf("END");
        return 0;
}

I just started learning Ncurses and have some questions:
i understand that initscr() is used for windows parameters initialization.

the first thing which is worrying me is:
win = newwin(10,10,10,10);

this is creating me a window some where near middle of the the monitor.

---> my problem is :
how to choose those values n_lines , n_cols, y and x.
i assume that n_lines indicates the no of characters that can be seen on the screen at a time in line by line fashion.
i assume that n_cols indicates the no of characters that can be seen on the screen at a time ( one by the side of another ).

then y and x i dont understand from where it starts :

this is with respect to creating a window and a box .

the second problem is mvwprintw(win , 13, 14, "Enter any Key :\n "); this statement is not getting printed on the screen.

and the program is getting many refresh and wrefresh statements.
is there any way to reduce them .

Your opinion , answers , guidelines are greatly appreciated.
thanks

Recommended Answers

All 3 Replies

#include<ncurses.h>
int main()
{
        WINDOW *win ;
        initscr();
        win = newwin(10,30,10,10);
        box( win, ACS_VLINE, ACS_HLINE);
        refresh();
        wrefresh(win);
        mvwprintw(win , 13, 14, "Enter any Key :\n ");
        refresh();
        wrefresh(win);
        getch();
        refresh();
        wrefresh(win);
        endwin();
        printf("END");
        return 0;
}

I just started learning Ncurses and have some questions:
i understand that initscr() is used for windows parameters initialization.

the first thing which is worrying me is:
win = newwin(10,10,10,10);

this is creating me a window some where near middle of the the monitor.

---> my problem is :
how to choose those values n_lines , n_cols, y and x.
i assume that n_lines indicates the no of characters that can be seen on the screen at a time in line by line fashion.
i assume that n_cols indicates the no of characters that can be seen on the screen at a time ( one by the side of another ).

then y and x i dont understand from where it starts :

this is with respect to creating a window and a box .

the second problem is mvwprintw(win , 13, 14, "Enter any Key :\n "); this statement is not getting printed on the screen.

and the program is getting many refresh and wrefresh statements.
is there any way to reduce them .

Your opinion , answers , guidelines are greatly appreciated.
thanks

I just rectified the problem and its working fine now.

but the other problem is reading the numbers and displaying on the window.

do we have any function to read the integer/float data from keyboard and place it in window.
because i want to devolop a program as below:

Num1 : 20                                           Num2: 30
     
      Sum = 50      Diff = 10       Prod = 600      Quo = 1    Rem = 10

and after the control should wait at Num1 :_( here) and take the other numbers and produce the result. it should keep on doing the same until i press quit.

please some one let me know if you have any idea.

Thank you,

What input functions are available with ncurses?

What input functions are available with ncurses?

Ohh ...! i did not check the man pages. i actually got the required functions.
scanw, wscanw, and others .

still facing problems, anyways i will post it here soon.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.