Originally Posted by
CommonTater
You need to post the minimum code sample that will demonstrate the problem.
We are not mind readers.
Here is the concerning part of the code:
Code:
for(a=1; a<=machines; a++)
printf(" %d machine: %d, %d, %d, %d\n", a, sort[number-a], sort[number+a-(2*machines)-1], sort[number-a-(2*machines)], sort[number-(4*machines)+a-1]);
Here, it generates arrays like sort[-1] or sort[12] and prints random values for them. I don't want this. I want it to print the ones that are between sort[0] and sort[11]. Is my problem clear now? Is there a way to do this?
Originally Posted by
\007
I don't quite get your question. So your indexes are randomly generated? Or the values in the array are?
If you want to print the contents between two ranges, create a function to do it. The function will accept an array and two ints, One for the start and one for the end of the range of the indices you want to print.
If you want to limit the range of a random number generator use a little mod math. rand() % 11 etc.
They're not randomly created, the problem is their indexes are changeable. There are functions inside the index part of the array, so there I am getting thing like a[-1] too as a result of the function inside and I don't want them to be printed with random values that system generates. I posted my part of code, so you can see there. Can I eliminate them?