By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,131 Members | 2,140 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,131 IT Pros & Developers. It's quick & easy.

code

P: 7
wat does this code do?
#include <stdlib.h>
#include <stdio.h>

int main( void )
{
int i, j, s[100];

int s_randomize(unsigned int s);

j = 1 + (rand() % 100);
printf( " %d\n", j );
return 0;
}
Mar 14 '07 #1
Share this Question
Share on Google+
7 Replies


RedSon
Expert 5K+
P: 5,000
It probably does nothing good since s_randomize isnt a standard library call. Did you write s_randomize? How is it declared?
Mar 14 '07 #2

Banfa
Expert Mod 5K+
P: 8,916
Like RedSon says s_randomize is not a standard library function but since you only declare it and don't call it that is not really relevent.

Since you call rand without seeding the random number generator my guess is that what this program does is print the same value every time you run it.

(On my system, VC++ 6, that just happens to be 42 :D )
Mar 14 '07 #3

RedSon
Expert 5K+
P: 5,000
You lie like a rug! ROFL
Mar 14 '07 #4

Banfa
Expert Mod 5K+
P: 8,916
You lie like a rug! ROFL
Hey, not fair. No lie told I compiled and ran that program at least 3 times all with the same result :p
Mar 14 '07 #5

RedSon
Expert 5K+
P: 5,000
No this is the program you ran:

Expand|Select|Wrap|Line Numbers
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. int main( void )
  5. {
  6. int life, universe, everything[100];
  7.  
  8. int j = Exec("Deep Thought", life, universe, &everything);
  9.  
  10. j = 6 * 9;
  11. printf( " %d\n", j );
  12. return 0;
  13. }
  14.  
Don't try to fool me
Mar 14 '07 #6

Ganon11
Expert 2.5K+
P: 3,652
Blasphemy!

(P.S. you define j as Exec(...) and then immediately reassign it to 6 * 9. Trying to double-cross Deep Thought!?)
Mar 14 '07 #7

RedSon
Expert 5K+
P: 5,000
OMG!!!!!! there is an error in the code for the Second Most Powerful Computer ever created!
Mar 14 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.