Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C pointers

Name: Anonymous 2011-12-05 20:36

/prog/ i have a problem.

I have an array of structs -> 400 in size and i do basic shit with them:


loop i:=0 -> 7^3
  Let s = struct @ i
  loop j:=0 -> 7^3 | j != i
    EditInnerStructValues(s,struct @ j);
//7^3 as in 7 to the 3rd power


This works for i:=0->16 THEN at i:=16 struct @ 242 changes it's pointer value to 0xFF800000 and this lasts till j:=19 at which point the pointer value then changes to 0xFFC00000.

I've checked my code over and over again and I've found no conclusion as to why it's doing this. If i change the length of the array to 6^3 or less it works fine. Anything >=7^3 lengths error out at a certain value with the same issue as described above.

Does /prog/ have any idea why this might be occuring?

Name: Anonymous 2011-12-05 20:41

Are you an queer!

Name: Anonymous 2011-12-05 20:46

>>2
No, I've also tried the looping without

EditInnerStructValues(s,struct @ j);


but I don't see how anything could be screwing up the pointers in there (especially when pointer #262 is not sent in there when it supposedly is changed)



void EditInnerStructValues(a,b){
  assert(a);
  assert(b);
  float
    dx = b->x - a->x,
    dy = b->y - a->y,
    d  = sqrt(dx*dx + dy*dy);
  float f;
  d = d * d;
  f = 5/d;
  a->xx = (f*dx)/d;
  a->yy = (f*dy)/d;
}

Name: Anonymous 2011-12-05 20:51

>>3
Also to add to that it the pointer @ index 262 changes between:

  a->xx = (f*dx)/d;
  a->yy = (f*dy)/d;


Both times when it changes values from normal -> 0xFF800000 -> 0xFFC00000 occur within those two lines.

Name: Anonymous 2011-12-05 21:49

bump

Name: Anonymous 2011-12-05 22:39

>>1
That doesn't look like C to me.

Name: Anonymous 2011-12-05 22:53

assert(1ull << 65);

Name: Anonymous 2011-12-06 0:22

problem solved : float was approaching infinity and i didn't account for that and that fucked up everything.

Name: Anonymous 2011-12-06 0:28

>>8
What language are you using?

Name: Anonymous 2011-12-06 0:35

>>9
C

Name: Anonymous 2011-12-06 0:41

>>10
Which C compiler considers the code posted in >>1 valid C code?

Name: Anonymous 2011-12-06 4:01

>>11
#include <void.h>

Don't change these.
Name: Email:
Entire Thread Thread List