由trubo c轉移到dev c++後產生的問題
請教一下,下面的程式,是用Turbo C寫的
可是,當我轉移到Dev C++上面開發時,出現了
[Linker error] undefined reference to `delay'
[Linker error] undefined reference to `randomize'
[Linker error] undefined reference to `random'
[Linker error] undefined reference to `gotoxy'
[Linker error] undefined reference to `clrscr'
我想應該是編譯的參考檔 .h的差異造成的吧?!
現在想問幾個問題:
1.如何在dev c++內編譯這個c語言程式?或者要作哪些修改?
2.假如dev c++內不能編譯,請問windows環境內還有哪一套免費的c語言編譯軟體可以編
譯呢?
附上原始程式如下,謝謝!
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <stdlib.h>
#include <dos.h>
int horse[8];
void mainmenu(void);
int painthorse(int);
void clrhorse(int);
main()
{
int n,win,ch;
//clrscr();
while(1)
{
while(1)
{
//clrscr();
printf("Please input the number of the horse which you want bet on.(0 to
7)");
scanf("%d",&n);
if ((n>7)||(n<0))
{
printf("Error number of the horses.\n");
delay(500);
}
else
{
printf("\nOK! you select no: %d's horse...\npress any key to start",n);
getch();
break;
}
}
int i;
for (i=0;i<8;i++)
horse[i]=1;
mainmenu();
randomize();
i=0;
while(1)
{
clrhorse(i);
horse[i]+=random(3);
win=painthorse(i);
delay(15);
if (win!=9) break;
i=i+1;
if (i==8) i=0;
}
gotoxy(1,20);
printf("no: %d of the horse winning!!\n",win);
if (win==n)
printf("Waoo, you got it! You are so clever!\n");
else
printf("Don't worry. You may get the champion at the next time!\n");
printf("Would you want to play the game again?(Y/N)");
ch=getch();
if (toupper(ch)=='N') break;
}
}
void mainmenu(void)
{
int i,j;
clrscr();
for (i=0;i<8;i++)
{
printf("\n");
for (j=0;j<70;j++)
printf("=");
printf("\n");
}
}
int painthorse(int i)
{
int win;
gotoxy(horse[i],i*2+1);
printf("%c",i+48);
if (horse[i]>=70)
win=i;
else
win=9;
return win;
}
void clrhorse(int i)
{
gotoxy(horse[i],i*2+1);
printf(" ");
}
--
┌─────◆KKCITY◆─────┐ ◢ ◤ 動態歌詞 讓你成為K歌之王!
│ bbs.kkcity.com.tw │ \^_^ / ★ http://www.kkbox.com.tw ★
└──《From:14.19.19.91 》──┘ ◤ 唱片公司授權,音樂盡情下載
--
討論串 (同標題文章)
Programming 近期熱門文章
PTT數位生活區 即時熱門文章