You are not logged in.
Pages: 1
Hello!
I am trying to learn a bit C (only for fun), and I wrote a little code with ncurses.
It works on FreeBSD, but I can't run it on DEVUAN.
libncurses5-dev and libncursesw5-dev are installed, the program compile just fine but nothing shows up in the terminal.
Is somebody knows what I am talking about?
Merci.
Fabien
Offline
Hi,
Sorry to insist, nobody?
Offline
I have no experience with ncurses.
You say "the program compile just fine", just to make sure - you did compile it on Devuan?
How are you running it, from a terminal? Are any error messages displayed in the terminal?
If you are sure its running, and there are no errors anywhere, then I would add printf's in your code to see where your program is at runtime:
printf("HERE 1.\n");
...
printf("HERE 2.\n");
...
Offline
You do know how to leave an audience guessing
Perhaps you should test the waters at the freenode IRC #devuan as well, to increase the chances of running into someone else doing C with ncurses on both freebsd and devuan. It might be a more select group than this one.
Offline
I have no experience with ncurses.
You say "the program compile just fine", just to make sure - you did compile it on Devuan?
How are you running it, from a terminal? Are any error messages displayed in the terminal?
If you are sure its running, and there are no errors anywhere, then I would add printf's in your code to see where your program is at runtime:
printf("HERE 1.\n"); ... printf("HERE 2.\n"); ...
Hi, i did compile it on Devuan using Geany.
There is no error message.
I will try your tip, thank you! I should of do it already, i am afraid i am a bit slow
Thank you!
Offline
You do know how to leave an audience guessing
Perhaps you should test the waters at the freenode IRC #devuan as well, to increase the chances of running into someone else doing C with ncurses on both freebsd and devuan. It might be a more select group than this one.
I hope I wasn't rude.
Thank you I will try that too
Last edited by fabien (2019-03-30 22:16:41)
Offline
Where is the code?
*๐๐๐๐๐๐!*
Offline
Thank you for helping.
#include <time.h>
#include <ncurses.h>
WINDOW *create_newwin(int h, int l, int y, int x)
{ WINDOW *local_win;
local_win = newwin(h, l, y, x);
box(local_win, 0 , 0);
wrefresh(local_win);
return local_win;
}
int main(int argc, char **argv)
{
WINDOW *win;
int x, y, h, l; // window
int px, py; // chicken
int v1x; // car 1
int ch, top = 0;
initscr();
cbreak();
keypad(stdscr, TRUE);
nodelay(stdscr, TRUE);
curs_set(0);
h = 30;
l = 60 ;
y = (LINES - h) / 2;
x = (COLS - l) / 2;
py = 1;
px = 30;
v1x = 1;
while ((ch = getch()) != 'q' && (py != 10 || px != v1x)){
if (clock() > top + 10){
top = clock();
win = create_newwin(h, l, y, x); // car crossing the window
mvwhline(win, 10, 1, '.', 58);
mvwaddch(win, 10, v1x, 'V');
v1x++;
if (v1x > 58)
v1x = 1;
}
switch(ch){ // chicken moves
case KEY_LEFT:
px--;
break;
case KEY_RIGHT:
px++;
break;
case KEY_UP:
py--;
break;
case KEY_DOWN:
py++;
break;
}
mvwaddch(win, py, px,'P');
wrefresh(win);
mvwaddch(win, py, px,' ');
}
endwin();
return 0;
}
Offline
~/tmp4c$ cat /etc/devuan_version
ascii
~/tmp4c$ ls -l
total 4
-rw-r--r-- 1 yeti yeti 1293 Mar 30 23:05 main.c
~/tmp4c$ gcc main.c -lncurses -o main
~/tmp4c$ ls -l
total 16
-rwxr-xr-x 1 yeti yeti 9216 Mar 30 23:14 main
-rw-r--r-- 1 yeti yeti 1293 Mar 30 23:05 main.c
It compiles without errors.
Started with
~/tmp4c$ ./main
it runs and I can move the P with the arrow keys.
Last edited by yeti (2019-03-30 23:26:12)
*๐๐๐๐๐๐!*
Offline
Ah...
Thank you, I will check that.
Offline
Pages: 1