Thread: curses[help]

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    227

    curses[help]

    i just have one last question before i go on learning some more...
    i have coded a simple hello word but in curses... now my problem is that it wont print out the hello word...
    but if i was to take out endwin(); from the code then it will print but yet my terminal starts to act as if it was in a loop but then again it prints out "hellow word"... can anyone tell me why.. ?

    Code:
     
    
    #include <curses.h> 
    
    int main()
    {
       initscr();   //starts the loop
         printw("hello word");   //prints hello word
        refresh();   //prints it to the real screen // stdscr
         endwin();  //ends curses
    }
    im trying to figure it out but ... i dont know what is going on.. so alittle help would be great ...... thanx

  2. #2
    The Artful Lurker Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633

    Re: curses[help]

    Originally posted by xlordt
    now my problem is that it wont print out the hello word...
    Ah, but it is printing 'hello world'! The problem is when you call endwin(), the output disappears. Try this as a confidence booster:
    Code:
    #include <curses.h> 
    
    int main()
    {
      initscr();   //starts the loop
      printw("hello word");   //prints hello word
      refresh();   //prints it to the real screen // stdscr
      sleep(2); /* curses.h includes what we need to sleep */ 
      endwin();  //ends curses
    }
    Jason Deckard

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    227
    see what i did was i added getch() but then again getch doesnt for all the times.. so i will not try sleep() i hope that works for the rest of the progz..
    thanx for your help

  4. #4
    The Artful Lurker Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633
    Glad I could be of help. The purpose of the sleep() statement was to let you see that the message was being printed (before being wiped out), and probably shouldn't be used outside of basic examples such as the one I provided.
    Jason Deckard

  5. #5
    Registered User
    Join Date
    Dec 2001
    Posts
    227

    Talking

    ya i can see thanx again... i sure hope i can get better at curses cause there are not to many tutorials out there... do you know a book that helps you learn curses.. ?

Popular pages Recent additions subscribe to a feed