Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why does this supposed to smooth function in C fail?
#21
Rel: Yep, except you'd get an "identifier s not defined" error there, but yeah you get the idea. I don't know how to do that wih malloc'd arrays.

Quote:
Sterling Wrote:
Code:
int array[10];
array[5000] = 1234;
In QB, this is also possible ;)
Huh? QB and C are very different about this:

QB would detect that as an error, stop the program, and inform you. It does this by inserting checks to make sure your not going outside the bounds of the array.

C does no such checks, instead it just overwrites whatever memory is where the 5000nth element would be, which usually crashes the program, if not worse.

Right?
Reply
#22
Just trid this:

1. This works

Code:
char array[256];

unsigned int asize = sizeof[array]
//returns 256
2. This does not

Code:
char *array;

array = malloc(256);

unsigned int asize = sizeof[array]
//returns 4 (the size of pointer probably)


How did you guys implement Ubound?

I was hoping that if I could, I'd just pass the pointer to a function and get the size of the array using that pointer.
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)