curses[help] [Archive] - C Board

PDA

View Full Version : curses[help]


xlordt
04-15-2002, 03:24 AM
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.. ?



#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

Deckard
04-15-2002, 05:36 AM
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:

#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
}

xlordt
04-15-2002, 08:05 AM
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 :)

Deckard
04-15-2002, 08:58 AM
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.

xlordt
04-15-2002, 01:49 PM
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.. ?