User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 375,238 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,123 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:

c language problm, how to pass pointer to a function

Join Date: Sep 2004
Posts: 6,009
Reputation: Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of 
Rep Power: 26
Solved Threads: 413
Super Moderator
Narue's Avatar
Narue Narue is offline Offline
Expert Meanie

Re: c language problm, how to pass pointer to a function

  #2  
Oct 1st, 2004
>plz explain me with syntax "how to pass pointer to a function or pointers to a function "
For each level of indirection in the function argument list, add an asterisk. If the argument isn't already a pointer of the same type as the argument list, dereference or add & as necessary.

>plz tell me if there any big tutorial which can solve my problem providing a deep knowledge about it
http://pweb.netcom.com/~tjensen/ptr/pointers.htm

>what is incorrect int following program.
A lot, actually. First and foremost you forgot to include stdlib.h, an error that the casting of malloc's return value hid and is a good example of why you don't cast the return of malloc. Second, you don't provide a prototype for func even though the definition is after the first call. a is a pointer to a pointer to int yet func expects a pointer to int so that's a type mismatch, you test for null pointers after dereferencing the allocated memory so the damage would already have been done by that point. All in all, the code could be improved greatly, but I'll leave that to you after you look at the link I gave you.
Member of: Beautiful Code Club.
Reply With Quote  
All times are GMT -4. The time now is 4:25 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC