- 论坛徽章:
- 0
|
[root@localhost chap10]# gcc -o ball ball.c -lcurses
/usr/bin/ld: cannot open output file ball: 权 权限不 权限不够
collect2: ld returned 1 exit status
[root@localhost chap10]#
在虚拟机安装的centos中编译
出现这个问题
请问怎么解决啊?
需要什么权限啊~
百度了下,也没什么好办法
谢谢大家了啊- #include<curses.h>
- #include<time.h>
- #include<sys/time.h>
- #include<signal.h>
- #include<stdio.h>
- #define MAX(a,b) a>b?a:b
- #define MIN(a,b) a<b?a:b
- int col = 10;
- int row = 10;
- int direction = 1;
- char ball = 'O';
- int barx = 10;
- int bary = 10;
- char *bar = "__________";
- int bar_len = 10;
- int set_ticket(long n_msecs){
- struct itimerval new_timeset;
- long n_sec ,n_usec;
- n_sec = n_msecs/1000;
- n_usec = (n_msecs%1000)*1000L;
- new_timeset.it_interval.tv_sec = n_sec;
- new_timeset.it_interval.tv_usec = n_usec;
- new_timeset.it_value.tv_sec = n_sec;
- new_timeset.it_value.tv_usec = n_usec;
- return setitimer(ITIMER_REAL,&new_timeset,NULL);
- }
- void paint(){
- clear();
- mvaddstr(bary, barx, bar);
- mvaddch(row, col, ball);
- refresh();
- col+=direction;
- if(col == COLS){
- direction = -1;
- col = COLS-1;
- beep();
- }
- if(col < 0 ){
- direction = 1;
- col = 0;
- beep();
- }
- }
- int main(int argc, char *argv[]){
- WINDOW *win;
- int input;
- long delay = 100;
- win = initscr();
- crmode();
- noecho();
- keypad(win,TRUE);
- signal(SIGALRM,paint);
- set_ticket(delay);
- while((input=getch())&&input!=ERR&&input!='q' ){
- switch(input){
- case 'f':{
- delay/=2;
- set_ticket(delay);
- break;
- }
- case 's':{
- delay*=2;
- set_ticket(delay);
- break;
- }
- case KEY_RIGHT:{
- barx = MIN(barx+1,COLS-1-bar_len);
- break;
- }
- case KEY_LEFT:{
- barx=MAX(barx-1, 0);
- break;
- }
- }
- }
- endwin();
- return 0;
- }
复制代码 |
|