I was humming along, and decided to try out data sorting. So, I did a few pieces of research, and came up with a really cool looking algorithm: Quicksort. I did what I should have, and started to program. Now, here is where I sound like an idiot:
Why is this not working?

The code is attached below. I wrote it up in Microsoft Visual Basic C++ 2010 Express. Every time I run it it gets the following error, and I cannot for the life of me find out why. Any help (at all) would be greatly appreciated, as I am new to C++ (I did Java mostly before this).

Thanks in advance,
EneilShade

Your statement

int Size = sizeof Array / sizeof Array[0];

will not work if Array is a formal parameter, because in that case, Array is simply a pointer and sizeof Array is the size of a pointer. If you want to use an array parameter to represent an array, you have to pass the size separately.

Wow... I had looked at the Wikipedia page wrong... I hate learning something wrong from the beginning. My problem was with a fundamental understanding of quicksort, nothing else.

Your statement

int Size = sizeof Array / sizeof Array[0];

will not work if Array is a formal parameter, because in that case, Array is simply a pointer and sizeof Array is the size of a pointer. If you want to use an array parameter to represent an array, you have to pass the size separately.

Thanks, but I had solved this just before you posted. But that comment will help me in the future!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.