Quote:
Originally Posted by twobob
Heh. well I am
but I just cant seem to figure out if I cast or what that third argument?
Ah well. Ill figure it out! thanks for the 101
|
I strongly recommend renaming all pointer vars to start with a "p" (for pointer). Either p_var for all lowercase, or pVar for camelCase var names.
In your example:
float result = highpass(signal, frequency, *delayed_signal, vector_size, float sr);
the * on *delayed_signal means delayed_signal is a POINTER that contains an ADDRESS. It should be DEFINED like this:
float *delayed_signal;
The * in front of it dereferences it returning the VALUE that it points to. Inside that call the way you are doing it
In the above call, the third parameter is just a value (not an address) being sent in the call. Now, if the function PROTYPE called for a third parameter of type "float *delayed_signal", then you are calling it incorrectly with a "*" in the call. Instead should pass either a pointer var
that it is sending the ADDRESS of the delayed_signal var in the call
On a side note, some people like to move the * (as in "float* signal;") but that can be CONFUSING when there are multiple variables on that line. For example:
float* a,b,c;
looks like a,b,c are all of type "float*", but it really means float *a,b,c;
where only a is a pointer var. So do not be tempted to DO that then. Okay?
Any help? Or just more befuddlement? I strongly recommend a little book called K&R. I fondled my first edition lovingly and repeatedly when it first came out. And read some source code too. A lot can be learned from working source code.
Here is a little "C pointers" google fu for you:
http://www.openismus.com/documents/c...pointers.shtml
And deeper geekness pointer fu for you too:
http://www.thegeekstuff.com/2012/01/...ed-c-pointers/