Home » Posts tagged "pointers"

Multidimensional Arrays without Subscript Operator

Some time ago friend of mine asked me how to operate on array without subscript operator, and – to be honest – I supposed it’ll took less than few hours…

NOTE as for all pointer arithmetic it’s rather inadvisable to use this trick in ‘common life projects’.
But I have some more knowledge so I’m sharing! (:
And if you want something more about pointer arithmetic you can check my previous article. Read more

Basic Void pointer arithmetics

Okay, as promissed before my last trek journey (polish only) I’ll share some C/C++ informations I found interesting.

Few hours before trip a friend of mine asked to write bubble sort. Easy. So I wondered where’s the catch – this guy created img processing tool in java. Our conversation beyond this point was something like:

I: “Why don’t you write it down yourself? You are better than me”
Bob: “I need to write it in C++”
I: “Ok, that’s some point. But Java and C++ syntaxes aren’t that different you know”
Bob: “But header for this sort function must be the same as qsort’s.”

And that was the catch. You need to work on void pointers, and that can be confusing for some.

void qsort (void* base, size_t num, size_t size,
            int (*compar)(const void*,const void*));

Call me good-hearted but I did that. I needed to finish packing, cooking my version of „iron ration” and so on, and doing bubble sort seemed easier than explaining how to do it.
Read more