Background: I made a copy of stdlib.h file and edited RAND_MAX to a much lower number so that my program generates random numbers in the range of my interest... i.e. max = 47.
Here is a snip of the code. When I compiled & ran my program, it generated the same thing as if I had not modified anything.
I put the mstdlib.h file in the directory that my compiler goes to when specifying and external .h file. No compiler errors, but I still get the same random numbers up to the old RAND_MAX.
Here is a piece of my modified stdlib.h:
Now 2f is a hex value equivalent to 47.
/* Maximum value that can be returned by the rand function. */
#define RAND_MAX 0x002f
* Maximum number of bytes in multi-byte character in the current locale
* (also defined in ctype.h).
How is it possible that when building the solution I still get the same high numbers as if I were using the original stdlib.h file?
I even closed my compiler & reloaded everything. I have already found a solution for limiting the rand() return value on this board: Cprogramming.com Tutorial: Generating Random Numbers
But now my question is why didn't using a modified stdlib.h didn't do the trick? I have spent the last 3 hours researching this on the FAQ and Google.
Maybe I'm using the wrong search strings here on the FAQ. Thanks!