Oh, it will. But unfortunately the fun doesn't stop at just 1500 times...
SUNTANG! THINK! Why is that happening? How many rows did you code that loop to allocate?
for(r=0; columns;...
Type: Posts; User: MK27
Oh, it will. But unfortunately the fun doesn't stop at just 1500 times...
SUNTANG! THINK! Why is that happening? How many rows did you code that loop to allocate?
for(r=0; columns;...
Main() should return an int.
You shouldn't cast the return value of malloc unless you need to use this code with a C++ compiler.
So, you do have an infinite loop in there >_<. Add this to the...
for(r=0; columns; r++)
Is obviously an infinite loop, since if columns is 1500, the middle condition will always be true. So this is not your actual code, this is some version of it. Making it...
That's what the new code will do, look:
i= (int) rand()0; // [sic]
if (arr[i][j] == 0.0) {
arr[i][j]= (double) rand()/RAND_MAX;
if (arr[i][j] > 0.0) {
m[j]++;
It does if the OP is just trying to avoid writing to the same index randomly more than once, but does not care if the value assigned is a duplicate of one at some other index (which is pretty...