Thread: Can't write to stdscr

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    131

    Can't write to stdscr

    When I today began learning ncurses API, I ran into a problem. I can't write into stdscr.
    I wrote few short programs, but none of them did work. I tried to write with printw(), mvprintw(), addch() and mvaddch() functions, but they didn't work. I tried to also write with printf() function in ncurses mode, but nothing happent. Writing with printf() while not in ncurses mode works fine.
    Version of ncurses library I'm using is 5.6. OS I'm using is Xubuntu GNU/Linux. Terminal emulator is Xfce-Terminal. Comipler is gcc 4.1.2. If someone needs more information, I can tell, or if I don't know, try to find out it.
    Last edited by fronty; 07-15-2007 at 10:20 AM.

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by fronty View Post
    When I today began learning ncurses API, I ran into a problem. I can't write into stdscr.
    I wrote few short programs, but none of them did work. I tried to write with printw(), mvprintw(), addch() and mvaddch() functions, but they didn't work. I tried to also write with printf() function in ncurses mode, but nothing happent. Writing with printf() while not in ncurses mode works fine.
    Version of ncurses library I'm using is 5.6. OS I'm using is Xubuntu GNU/Linux. Terminal emulator is Xfce-Terminal. Comipler is gcc 4.1.2. If someone needs more information, I can tell, or if I don't know, try to find out it.
    Probably ncurses closes all funny file descriptors, including stdscr, whatever that is. Just use stdout.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Do basic ncurses programs work for you?
    http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Have you called initscr() ? Are you calling refresh() ? Could you post a minimal not-working example?
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  5. #5
    Registered User
    Join Date
    Jul 2007
    Posts
    131
    Salem: No, they don't work.
    Cactus_Hugger: Yes, I have called initscr() and refreshed window after printing.
    And one minimal example:
    Code:
    /* Hello, World */
    
    #include <ncurses.h>
    
    int main(void) {
        initscr();
    
        printw("Hello, World!");
        refresh();
    
        endwin();
        return 0;
    }

  6. #6
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    fronty, got the ncurses library installed (ie not just ncurses-devel)

  7. #7
    Registered User
    Join Date
    Jul 2007
    Posts
    131
    I compiled only source package I found for version 5.6, so I think I have whole library installed. :/

  8. #8
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Your minimal sample may be running too quickly. Place a getch() right before the endwin() call.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  9. #9
    Registered User
    Join Date
    Jul 2007
    Posts
    131
    :/ Doesn't work. :/
    It seems to me it writes to it, but somehow it doesn't show it on teminal.

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    IIRC, there are a multitude of different terminal emulators on most Linux distros.
    Have you tried other ones?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  11. #11
    Registered User
    Join Date
    Jul 2007
    Posts
    131
    Tried with xterm, and with it works. Must try to find out why it didn't work with Xfce-terminal.

  12. #12
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 03-18-2006, 11:25 AM
  2. program to make a floppy write protected
    By shrijeetp in forum C Programming
    Replies: 1
    Last Post: 10-03-2005, 06:00 AM
  3. Reroute where programs write to
    By willc0de4food in forum C Programming
    Replies: 7
    Last Post: 09-21-2005, 04:48 PM
  4. Function to write string 3 times
    By Giggs in forum C++ Programming
    Replies: 15
    Last Post: 12-24-2002, 04:00 PM
  5. write in c
    By PutoAmo in forum C Programming
    Replies: 6
    Last Post: 04-03-2002, 07:53 PM