发新话题
打印

小菜求助!

小菜求助!

大家好 小菜我最近写了个c代码 但是链接不上去阿 不知道什么原因 代码和错误贴上 望那位大哥指点
#include<stdio.h>     //basic i/o
#include<curses.h>    //shell window control
#include<sys/time.h>
#include<stdlib.h>
#include<signal.h>    //signal();
#define COLS    30
#define message "hello"
#define blank   "     "
int row;
int col;
int dir;
int main()
{
int delay;    //delay time   
int ndelay;    //new delay time
int c;        //user input
void move_msg(int);    //handler for timer
initscr();
crmode();
noecho();
clear();
row=10;        //set initialize row value
col=0;        //set initialize column value
dir=1;        //set initialize direction
delay=200;    //ms
mov(row,col);    //move cursor to the specified location
addstr(message);//draw message in the specified location
signal(SIGALRM,move_msg);   
//specified move_msg to process the SIGALRM    message
set_ticker(delay);    //set new delay time to control speed in there
while(1)
{
ndelay=0;        //set new delay=0 when start
c=getch();        //get a char from input
if(c=='Q') break;
if(c==' ') dir = -dir;
if((c=='f')&&(delay>2))
ndelay=delay/2;   
// increase the speed by slow down the interval time
if(c=='s') ndelay=delay*2;        // slow down
if(ndelay>0)
set_ticker(delay=ndelay);        // reset delay&&timer
}
endwin();
return 0;                //procedure terminated
}
void move_msg(int signum)          //process the message from timer
{
signal(SIGALRM,move_msg);        //not necccessary
move(row,col);                //set blank
addstr(blank);
col+-dir;                //set new column
move(row,col);
addstr(message);            //set message
refresh();
if(dir==-1&&col<=0)            //when move to start
dir = 1;
else if((dir == 1) && (col + 7>=COLS))
dir=-1;
}
int set_ticker(int n_msecs)
{
struct itimerval new_timeset;
long n_sec,n_usecs;
n_sec=n_msecs/1000;
n_usecs=(n_msecs%1000)*1000L;
new_timeset.it_interval.tv_sec=n_sec;
new_timeset.it_interval.tv_usec=n_usecs;
new_timeset.it_value.tv_sec=n_sec;
new_timeset.it_value.tv_usec=n_usecs;
return setitimer(ITIMER_REAL,&new_timeset,NULL);
}
编译命令和提示的错误信息是
administrator@ubuntu:~$ cc bounceld1.c -l curses -o bounceld
/tmp/ccASgicj.o: In function `main':
bounceld1.c.text+0x5e): undefined reference to `mov'
collect2: ld returned 1 exit status
谢谢

TOP

回复 1# 的帖子

int main(void)

TOP

发新话题