Crunch Posted September 10, 2004 Share Posted September 10, 2004 I have an array of n numbers and I need to randomize the numbers in the array i know rand() is the answer to my problems but I am having trouble with an error error C2661: 'rand' : no overloaded function takes 1 arguments for (int x = 0; x < arraysize; x++) { rand(ptr[x]); } why doesnt that work? I forgot almost everything from last semester Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted September 10, 2004 Share Posted September 10, 2004 rand doesn't take an argument. it's int rand(void). Link to comment Share on other sites More sharing options...
0 Crunch Posted September 10, 2004 Author Share Posted September 10, 2004 well then how would I randomize an array? Link to comment Share on other sites More sharing options...
0 Crunch Posted September 10, 2004 Author Share Posted September 10, 2004 nvm i just thought of it rand() = ptr[x]; within the for-loop Link to comment Share on other sites More sharing options...
0 Crunch Posted September 10, 2004 Author Share Posted September 10, 2004 well mmm ptr[x] = rand(); there thats better Link to comment Share on other sites More sharing options...
0 zhwcn Posted September 10, 2004 Share Posted September 10, 2004 You can use a "for" loop to initialize a array。 Link to comment Share on other sites More sharing options...
0 shake Posted September 10, 2004 Share Posted September 10, 2004 just use the help that comes with the platform u r using (F1 if using borland/turbo C++ or just plain old msdn) and check out the proper arguments for the rand() function. rand() has no arguments ... also check out srand() that is used for initializing rand() Link to comment Share on other sites More sharing options...
Question
Crunch
I have an array of n numbers and I need to randomize the numbers in the array
i know rand() is the answer to my problems but I am having trouble with an error
error C2661: 'rand' : no overloaded function takes 1 arguments
for (int x = 0; x < arraysize; x++) { rand(ptr[x]); }why doesnt that work?
I forgot almost everything from last semester
Link to comment
Share on other sites
6 answers to this question
Recommended Posts