Eric.
Premium
- 8,515
- GTP_Eric
- Ebiggs
This just brought the work on my programming assignment to a halt.
One of the basic things to do in the assignment was to create 4000 normally distributed numbers (the program was to simulate a page replacement algorithm) from 0-39. The function call to return the integer in that range is called "get_rand_int()". The problem with the code lies in this section:
This should work just fine in Java. But C does not allow me to assign values within the int array if its done from a loop.
That will work when called directly by main, not in a loop.
How are you supposed to handle this?
One of the basic things to do in the assignment was to create 4000 normally distributed numbers (the program was to simulate a page replacement algorithm) from 0-39. The function call to return the integer in that range is called "get_rand_int()". The problem with the code lies in this section:
Code:
int page_ref[4000] = {0};
int i;
for(i = 0; i == 399; i++){
page_ref[i] = get_rand_int();}
This should work just fine in Java. But C does not allow me to assign values within the int array if its done from a loop.
Code:
page_ref[5] = get_rand_int();
How are you supposed to handle this?