我是新手,我實際上無法理解「未在範圍內聲明」錯誤的含義。我試圖將這些聲明爲函數,也使用「」來顯示函數,但它沒有編譯和運行。下面是錯誤:''未在此範圍內聲明
在函數「詮釋主()」:
[錯誤]「隨機」並不在此範圍內聲明
[錯誤]「聲音」是在此範圍內聲明
[錯誤] '延遲' 在此範圍內未聲明
[錯誤]'以上三個參數的未在此範圍內聲明
[錯誤] 'BLINK' 不是declar編輯在此範圍內
[錯誤]「textattr」在此範圍內未聲明
#include<stdio.h>
#include<iostream>
#include<dos.h>
#include<conio.h>
#include<stdlib.h>
using namespace std;
int main()
{
int count=50;
while(count--)
{
sound(90*random(10));
delay(100);
nosound();
textattr(random("16")+'a'+BLINK);
cprintf("KSHITIJ");
}
}
你想要的函數叫'rand()'而不是'random()'。 –
@πάνταῥεῖ看起來OP正在使用一些外部庫,假設字符串輸入爲'random',這可能是種子,我會說這是lib的一部分。也許某種類型的dos庫? –
一旦你得到這個運行,你也會遇到:http://stackoverflow.com/questions/9459035/c-rand-gives-same-number-when-running-process – NathanOliver