Re: [Dev-C++] Please help with program bugs, i tried, no luck.
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: ropbert d b. <lon...@ju...> - 2001-01-18 19:49:11
|
Here is a better program. Still have no idea why random not in dev-c++
lib. Anybody got any clue??
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
int roll(void); // protypes
int dice_1; // Declared globals
int dice_2;
int roll()
{
dice_1 = (random(6) + 1); // dev-c++ does not have random
function
dice_2 = (random(6) + 1); // that i can find . use bcc55 for
this
return dice_1; // anyone else have information on
random??
}
int main()
{
int through = 0;
randomize();
do
{
roll();
cout<<" the value rolled is : "<<(dice_1+dice_2)<<endl;
cout <<" the first die was : "<<dice_1<<endl; // changed to int
cout<<" the second die was: "<<dice_2<<endl;
cout<<"Enter 1 to quit " ;
cin>>through;
// system("pause"); // not needed now
}while(through != 1);
return 0; // screen in console
mode
}
On Thu, 18 Jan 2001 07:02:35 -0800 (PST) tayo odesanya <ta...@ya...>
writes:
> Intranet Compilers
> Compilation Results
>
> 1 #include <iostream.h>
> 2 #include <stdlib.h>
> 3
> 4 int dice_1;
> 5 int dice_2;
> 6 int roll()
> 7 {
> 8 randomize();
> 9 dice_1 = random(6) + 1;
> 10 dice_2 = random(6) + 1;
> 11 return dice_1;
> 12 return dice_2;
> 13 }
> 14 int die1()
> 15 {
> 16 return dice_1;
> 17 }
> 18 int dice_2()
> 19 {
> 20 return dice_2;
> 21 }
> 22 int main()
> 23 {
> 24 cout<<" the value rolled is : "<<roll()<<endl;
> 25 cout <<" the first die was : "<<die1()<<endl;
> 26 cout<<" the second die was:"<<die2()<<endl;
> 27 return 0;
> 28 }
>
> language: C and C++
> options: Display all warnings
> options: Include math library during linking
>
> prog.cpp: In function `int roll()':
> prog.cpp:8: implicit declaration of function `int
> randomize(...)'
> c:/djgpp/include/stdlib.h:121: too many arguments to
> function `long int random()'
> prog.cpp:9: at this point in file
> c:/djgpp/include/stdlib.h:121: too many arguments to
> function `long int random()'
> prog.cpp:10: at this point in file
> prog.cpp: In function `int dice_2()':
> prog.cpp:5: previous non-function declaration `int
> dice_2'
> prog.cpp:19: conflicts with function declaration
> `int dice_2()'
> prog.cpp: In function `int main()':
> prog.cpp:26: implicit declaration of function `int
> die2(...)'
>
> Errors Found!
>
> You need to correct the errors so that the program
> compiles. The compiler was executed remotely from
> MarketCache1.netcarrier.net/209.140.169.18 on
> Thursday, January 18, 101, 8:51.
>
>
>
> Send comments to:ole...@ie....
>
>
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.
> yahoo.com/
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|