Terry
Phil Middlemiss wrote:
One more question: The original C source code uses gotos. Does a "return" statement in C mean just leave the routine, or does it also return back to the next statement after the goto? I would assume that it does not continue after a goto statement, but this code is so convoluted I can't be sure what it intended to do just by looking at the code.Phil. ----- Original Message ----- From: "Terry" <[EMAIL PROTECTED]> To: "NZ Borland Developers Group - Delphi List" <[EMAIL PROTECTED]> Sent: Monday, April 19, 2004 12:18 PM Subject: Re: [DUG] Converting some code from CPointers and arrays are essentially equivalent in c. And pointer arithmatic works like array indexation, so ... *(snorm+n) = *(snorm+n-1)*(float)(2*n-1)/(float)n; and snorm[n] = *(snorm+n-1)*(float)(2*n-1)/(float)n; and snorm[n] = snorm[n-1]*(float)(2*n-1)/(float)n; are all equivalent statements. A reason you may wish to use the pure pointer form is where you don't want to pass an array and index offset into a function, you can just point to an element. And p++ will increment the pointer to the next array element (probably the reason p is used rather than snorm directly). Terry Phil Middlemiss wrote:I'm converting some code from some ugly C. The code defines oneparticulararray, and a constant like this: static float snorm[169]; static float *p = snorm; and then later has an assignment: *snorm = 1.0; and then again later (n is an integer iterator): *(snorm+n) = *(snorm+n-1)*(float)(2*n-1)/(float)n; The question is this: It looks like the code is simply assigning valuestoan array, so why bother with the pointers? Elsewhere the code uses arrays normally (ie. indexing them with the square brackets) so that makes methinkmaybe this is doing something other than just putting values into thearray.Also, I'm assuming that the "p" variable is just a pointer into snorm? Can anyone make this clear for me? Cheers, Phil. _______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi_______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi_______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
