This won't even compile due to the error:
1>c:\documents and settings\my documents\visual studio 2008\projects\bkttst\bkttst\bkttst.cpp(9) : error C2100: illegal indirection
Line 9 is the one with *array[0].
Comment out that line and the output:
...Well, yeah, no shit sherlock, you put a double pointer in for a variable that only had one pointer in the first place. Of course it won't compile. What's your point? I'm guessing you're totally missing what I'm saying? Like for the past 2-3 times now?
I was just establishing that arr[] is the same as an *arr. It's simply that *arr does not have a defined number of memory locations set aside to it, which can be fixed (at least in c) by something like:
double *arr= double *malloc(5);
That sets aside room for 5 doubles in a modifiable area of the memory.
You can then proceed to go
arr[0]= 41.41;
Or whatever the hell you want.
Also, indexing with double pointers should be something like this:
arr[0][0]
is equivalent to
**arr
and,
arr[1][0]
is equivalent to
*(arr[1])
or
**(arr+1)
and
arr[1][1]
is the same as
*(*(arr+1)+1)
or
*(arr[1]+1)
I'm honestly quite rusty with my programming, so you can go test it out for me, if you wish.
So can you now at last give up on *double[] ?
Here's the somewhat unrelated reason to why
I brought up the declaration of main and when
such syntax is used:
... Wtf? Give up on it? What the hell are you talking about? Unless C++ is just VASTLY different from C, I don't see where you're taking the *double[] argument to?
Moreover... his main function isn't even where the problem is. What the hell are you getting at?
I looked over your console function that takes inputs in from the user, and I don't see what point you're trying to make. You do realize that any NORMAL char declaration in C can only have one letter by itself? A mere word is already an array. For the first level of your character array's pointers, you put in space for 5 character pointers. Then, you proceeded to give each of those character pointers their own array. In essence, this is a double pointer. I believe you're just proving exactly what I said, so I don't see what your point is.
You do **mystrings after the user input and you'll just get out the letter h, which makes sense, because mystrings is an array of pointers to arrays of pointers which point to letters, and you're pretty much saying mystrings[0][0].
And while I'm at it why not poke a hole at your
array-gets-copied-and-can't-be-modified statement:
Poke a hole in? If you look at edit 2 at the bottom of my post, you'll see that I realized that it may just copy addresses and thus make it modifiable, and I said that. Thanks for making sure, though. I've personally never had a situation where I've had to modify an array like that, but that's because most of the stuff I was dealing with were dynamically allocated data structures like binary trees, nary trees, and linked lists. Something as simple as modifying a numerical array isn't a part of my (recent) experience.
Please, do test your stuff before you start
giving advice if you're not sure you're right.
... No, I don't really feel like opening Visual Studio to test something like this.
I mean, I don't know where the hell you're headed with YOUR argument (nowhere?), but the topic creator's original problem (which I am addressing) was that he was sticking in a pointer into a function that took a double pointer. For that branch, everything I said makes sense. For the corrections I suggested in my post, the a few can be cut off now that I know that arrays can be modified inside of the function. That's about it. On a side note, though, C++ has some nice convenient little things. Lol @ the "delete" and "new" commands. In C, this would have been more of a pain.
However, I have to applaud this:
call scores like this
sort(&scores, numtest);
That's brilliant. I totally forgot about the & (address) operator. That should mostly fix your stuff, Gogeta. There might be a few errors inside the actual function, but this should fix the error you're getting right now.