Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > callback function

Reply
Thread Tools

callback function

 
 
Bill Cunningham
Guest
Posts: n/a
 
      10-18-2012
Bill Cunningham wrote:
> Keith Thompson wrote:
>
>> You're posting code that you haven't even tried to compile?
>>
>> Please don't waste our time.

>
> Why do some people post untested code? I didn't know it was against
> the rules. I've seen it alot. It's tested now and works perfectly.


Also untested code illustrated my point and answered my question
perfectly. I'm just in the *out* group.

Bill


 
Reply With Quote
 
 
 
 
Bill Cunningham
Guest
Posts: n/a
 
      10-18-2012
John Gordon wrote:

> Whoops, I was mistaken. If you're getting the size of a variable you
> don't need parentheses. But if you're getting the size of a type,
> you do
> need them.
>
> (And it's an operator, not a keyword. Wrong all around!)


That's fine John I appreciate your opinion though yes you where wrong.
No problem. But be forewarned, this *could* be the start that leads you to
the *outgroup* If you start asking questions especially you should know as a
computer programming expert (ingroup) and sticking yourself out there...Be
careful.

Bill


 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      10-18-2012
"Bill Cunningham" <(E-Mail Removed)> writes:
> Keith Thompson wrote:
>
>> You're posting code that you haven't even tried to compile?
>>
>> Please don't waste our time.

>
> Why do some people post untested code? I didn't know it was against the
> rules. I've seen it alot. It's tested now and works perfectly.


Your code wasn't merely untested; you hadn't even compiled it.
It wasn't a violation of some specific rule, it was a violation of
common sense. You didn't bother to spend a minute or so compiling
your code before you posted it here. The code you posted was full
of syntax errors that anyone trying to help you would have to fix
before answering your actual question.

int comp(constvoid *a,const void *b)

Why should I spend time fixing errors like this, not relevant to the
question you're asking, that you could have fixed yourself? How is
anyone supposed to know which errors are just typos, and which are
relevant to the problem you're trying to solve?

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Bill Cunningham
Guest
Posts: n/a
 
      10-18-2012
Keith Thompson wrote:

> Your code wasn't merely untested; you hadn't even compiled it.
> It wasn't a violation of some specific rule, it was a violation of
> common sense. You didn't bother to spend a minute or so compiling
> your code before you posted it here. The code you posted was full
> of syntax errors that anyone trying to help you would have to fix
> before answering your actual question.
>
> int comp(constvoid *a,const void *b)
>
> Why should I spend time fixing errors like this, not relevant to the
> question you're asking, that you could have fixed yourself? How is
> anyone supposed to know which errors are just typos, and which are
> relevant to the problem you're trying to solve?


I'll be more careful.

Bill


 
Reply With Quote
 
Bill Cunningham
Guest
Posts: n/a
 
      10-18-2012
Ian Collins wrote:

> The whole point of the parameters being const qualified is you can't
> change values pointed to.


Then why

return *pa-*pb;

B


 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      10-19-2012
"Bill Cunningham" <(E-Mail Removed)> writes:

> John Gordon wrote:
>
>> Whoops, I was mistaken. If you're getting the size of a variable you
>> don't need parentheses. But if you're getting the size of a type,
>> you do
>> need them.
>>
>> (And it's an operator, not a keyword. Wrong all around!)

>
> That's fine John I appreciate your opinion though yes you where
> wrong.


Actually he's not "wrong all around" -- sizeof *is* a keyword. It's an
operator, too, but it's also a keyword.

<snip sociology>
--
Ben.
 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      10-19-2012
"Bill Cunningham" <(E-Mail Removed)> writes:

> Ian Collins wrote:
>
>> The whole point of the parameters being const qualified is you can't
>> change values pointed to.

>
> Then why
>
> return *pa-*pb;


What's the connection with whether or not the pointers are to const-
qualified types or not? I can't see any connection between Ian's remark
and your reply.

--
Ben.
 
Reply With Quote
 
Bill Cunningham
Guest
Posts: n/a
 
      10-19-2012
Ben Bacarisse wrote:
> "Bill Cunningham" <(E-Mail Removed)> writes:
>
>> Ian Collins wrote:
>>
>>> The whole point of the parameters being const qualified is you can't
>>> change values pointed to.

>>
>> Then why
>>
>> return *pa-*pb;

>
> What's the connection with whether or not the pointers are to const-
> qualified types or not? I can't see any connection between Ian's
> remark and your reply.


There's been some kind of posting mixup here. I asked about dereferencing in
an earlier post and changing the object pointed to. He said that is why
const was used. I am asking then why these dereferences.

HTH
B


 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      10-19-2012
"Bill Cunningham" <(E-Mail Removed)> writes:

> Ben Bacarisse wrote:
>> "Bill Cunningham" <(E-Mail Removed)> writes:
>>
>>> Ian Collins wrote:
>>>
>>>> The whole point of the parameters being const qualified is you can't
>>>> change values pointed to.
>>>
>>> Then why
>>>
>>> return *pa-*pb;

>>
>> What's the connection with whether or not the pointers are to const-
>> qualified types or not? I can't see any connection between Ian's
>> remark and your reply.

>
> There's been some kind of posting mixup here. I asked about dereferencing in
> an earlier post and changing the object pointed to. He said that is why
> const was used. I am asking then why these dereferences.


And I am asking why you use the word "then". You seem to think there is
a connection between the issues of changing objects and pointers to
const types and these two dereferences. I'm just curious to know what
you think the connection is.

--
Ben.
 
Reply With Quote
 
Barry Schwarz
Guest
Posts: n/a
 
      10-19-2012
On Thu, 18 Oct 2012 18:24:37 -0400, "Bill Cunningham"
<(E-Mail Removed)> wrote:

snip

> And let me ask you as a programmer Ian and being in the *in* group an
>*outgroup*er question. What exactly do callback pointer functions help with.
>I know this should come from the womb but just and honest question.


There are callback functions and function pointers but what do you
think a callback pointer function is?

Consider the common case of qsort. It contains a sorting algorithm
which at some point needs to know what the relationship between to
array elements is. Unfortunately, it doesn't know what the type of
the array elements is and therefore cannot compare them internally.
You provide a compare function which qsort can "callback" to determine
the relationship. The function then returns the status of that
relationship to qsort which makes the appropriate processing decision
based on that status.

In general, callback functions provide a way for a user to tailor a
generic process by providing information specific to the current
application.

In this way the same qsort library function can be used once to sort
an array of pointer to double based on the value of the double and
again to sort an array of struct based on a character array in that
struct.

--
Remove del for email
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigning a member function to signal callback function pointer Ramesh C++ 11 12-27-2008 09:36 AM
How do I create a function in my library for passing user callback function Angus C Programming 32 04-15-2008 02:28 PM
can a class member function be used as a callback function? JDT C++ 6 03-29-2007 12:45 PM
Using function pointer in callback function pvdm C++ 1 09-09-2003 12:26 PM
Howto: Class member function as callback function for dialog box prettysmurfed C++ 6 07-22-2003 06:17 PM



Advertisments