LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-31-2004, 07:54 AM   #1
vegpl
LQ Newbie
 
Registered: Jan 2004
Location: ~
Posts: 28

Rep: Reputation: 15
ncurses window and keypad


In my main function I first declare a few variables and I then call
these functions:

Code:
initscr();
noecho();
cbreak();
keypad(stdscr, TRUE);
refresh();
I then draw a few horizontal and vertical lines on the "standard
screen".

Here is the code that follows the horizontal and vertical liness

Code:
new_win = newwin(5, 5, 20, 15);
box(new_win, 0, 0); 
wrefresh(new_win);

while (1) {
        
        ch = getch();
        
        printw("1");
        
        switch(ch) {
        
            case KEY_LEFT: ....
....
It compiles without any problems. When I execute, it draws the vertical
and horizontal lines and displays the window. As soon as I press the
left arrow key I get: Segmentation fault

It never prints the 1
 
Old 10-31-2004, 02:12 PM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
I'm not sure if printw() does it, but you can try doing fflush(stdout); after the printw().
 
Old 11-01-2004, 02:00 AM   #3
Nerox
Member
 
Registered: Jul 2004
Location: Spain
Posts: 111

Rep: Reputation: 20
Quote:
It never prints the 1
It's OK, it shouldn't print 1, because the screen is not refreshed after printw("1").
Could you write here the code after KEY_LEFT label?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ncurses, how to scroll window nazir Programming 1 08-05-2005 11:32 AM
keypad operation carthyc Linux - General 1 06-29-2005 06:49 AM
C programming HELP, ncurses window functions naomi Programming 3 02-06-2005 05:54 AM
Numerical keypad Craqon Linux - General 2 12-15-2004 12:42 AM
ncurses-5.2-28 conflicts with file from package ncurses-5.2-12 tubby Linux - Software 4 06-16-2002 12:00 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration