I\'m trying to write a program to that acts as a marquee that uses the curses.h library
to create a side-scrolling display.
What should happen is that my me
The first problem is that you call getmaxyx()
before initscr()
. In this situation, stdscr
has not been initialized, so the values returned by getmaxyx()
are meaningless. (I get -1 for each value, aka ERR.)
That fixed, the program basically works, but prints junk after the "Hello" string. You can solve that by changing the for loop test, text_length || i<max_x
, to text_length && i<max_x
, although the result is still probably not quite what you want. But I'll leave it to you to figure that one out.
Finally, as a stylistic matter, I'd suggest using curses' own napms()
function instead of usleep()
(i.e., napms(50)
instead of usleep(50000)
). But if you do stick with usleep()
, you should add #include <unistd.h>
at the top.