D
David Shaw
Hi,
I'm writing a fun little program to play "Petals Around the Roses"
with... I need to seed my random numbers so that they won't be the
same every time I run the program, but my compiler won't let me.
Here's the output my compiler generated...:
--
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Documents and Settings\rmarkoff\Desktop\roses.cpp" -o
"C:\Documents and Settings\rmarkoff\Desktop\roses.exe"
-I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32"
-I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include"
-L"C:\Dev-Cpp\lib"
C:/Documents and Settings/rmarkoff/Desktop/roses.cpp:7: ISO C++
forbids
declaration of `srand' with no type
C:/Documents and Settings/rmarkoff/Desktop/roses.cpp:7: `int srand'
redeclared
as different kind of symbol
C:/Dev-Cpp/include/stdlib.h:362: previous declaration of `void
srand(unsigned
int)'
Execution terminated
--
And here's my code:
#include iostream> // I took out the <
#include stdlib.h> // in these #includes
#include time.h> // so that they will work on the web.
using namespace std;
srand((unsigned)time(NULL));
int matrix[4];
void display(void) { // Start Display()
int x;
for(x=0;x<4;x++) { // Randomize matrix
matrix[x] = (rand() % 6) + 1;
} // End for()
std::cout << "\n----------------------------------" << std::endl;
std::cout << "|" << matrix[0] << "|" << "|" << matrix[1] << "|" <<
"|"
<< matrix[2] << "|" << matrix[3] << "|" <<
matrix[4] << std::endl;
std::cout << "----------------------------------" << std::endl;
} // end display()
int main() { // Start main()
display();
std::system("pause");
} // End main
.... thanks for any help you can give me.
- David Shaw
I'm writing a fun little program to play "Petals Around the Roses"
with... I need to seed my random numbers so that they won't be the
same every time I run the program, but my compiler won't let me.
Here's the output my compiler generated...:
--
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Documents and Settings\rmarkoff\Desktop\roses.cpp" -o
"C:\Documents and Settings\rmarkoff\Desktop\roses.exe"
-I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32"
-I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include"
-L"C:\Dev-Cpp\lib"
C:/Documents and Settings/rmarkoff/Desktop/roses.cpp:7: ISO C++
forbids
declaration of `srand' with no type
C:/Documents and Settings/rmarkoff/Desktop/roses.cpp:7: `int srand'
redeclared
as different kind of symbol
C:/Dev-Cpp/include/stdlib.h:362: previous declaration of `void
srand(unsigned
int)'
Execution terminated
--
And here's my code:
#include iostream> // I took out the <
#include stdlib.h> // in these #includes
#include time.h> // so that they will work on the web.
using namespace std;
srand((unsigned)time(NULL));
int matrix[4];
void display(void) { // Start Display()
int x;
for(x=0;x<4;x++) { // Randomize matrix
matrix[x] = (rand() % 6) + 1;
} // End for()
std::cout << "\n----------------------------------" << std::endl;
std::cout << "|" << matrix[0] << "|" << "|" << matrix[1] << "|" <<
"|"
<< matrix[2] << "|" << matrix[3] << "|" <<
matrix[4] << std::endl;
std::cout << "----------------------------------" << std::endl;
} // end display()
int main() { // Start main()
display();
std::system("pause");
} // End main
.... thanks for any help you can give me.
- David Shaw