Fun Stuff > CLIKC
A programming thread!
Masterpiece:
--- Quote from: snalin on 29 Apr 2014, 04:46 ---
--- Code: --- char get_line_intersection(float p0_x, float p0_y, float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, float *i_x, float *i_y)
--- End code ---
--- End quote ---
Return char? Whut?
snalin:
The person uses 0 for "they did not intersect" and 1 for "they did intersect". It's C code, basically. If whomever wrote it was actually writing C, it's fine, if they were writing C++, again, it's bullshit.
EDIT: to make it clear, C doesn't have built-in boolean values. It's low level, what-you-see-is-what-you-get, remember, so instead of wrapping 0 and 1 in a thing and calling it "boolean" or "bool", they just let you do that yourself.
snalin:
No, it does find the intersection point, and puts it in the variables *i_x and *i_y. Sending in primitive variables for storage is something you kinda have to do in C, and can do but really, really shouldn't in C++, C# (out keyword) and some other languages. Java does the correct thing and disallows that completely.
By the way, accepting arbitrary sized variables for output storage was how the Heartbleed bug happened, as far as I can remember.
EDIT: Oh you sneaky Masterpiece, removing your post so it looks like I'm insane, talking to shadows.
Masterpiece:
Sorry I just realized I was speaking nonsense, my mistake.
ev4n:
My kid is asking to learn some programming again. Really not sure where to steer them.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version