Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pointers to functions!!Please give a small tutorial

Status
Not open for further replies.

anvartk

Programmer
Dec 19, 2000
7
IN
I am confused about
advanced pointer concepts
of functions.
Give a small tutorial
or suggest any free tutorial or
a book
 
Hi
You can use the book "Pointer in C" by Yashawant Kanitkar or you can read "Writing TSRs in C" by Yashawant Kanitkar, the first 3 chapters to get an overview of the functions to pointers. Hope this helps you.

Regards
Siva
 
Well MSDN should provide enough information on this and not to forget the online help provided along with all compilers.
For a sample here is a short code..
..

#include <stdio.h>

void (*func)(int);
void myfunction (int x);

int main ()
{

func = myfunction; // associate to the function pointer
(*func)(10);
getch ();

return 1;
}

void myfunction (int x)
{
printf (&quot;Value = %d&quot;, x);
}
 
If you don't already have it, get The C Programming Language (K&amp;R2). It has excellent explanations of function pointers.

anvartk, if you could ask a more specific question, we might be able to help you better. What *exactly* are you confused about?

sriks, did you pull that from MSDN??



Russ
bobbitts@hotmail.com
 
Well, I have just decided to learn C about 1 to 2 months ago and now I am stuck on Converting binary numbers into decimals and viceversa can you help me on that?
 
Hi,

To convert a string of 1's and 0's into a decimal number, you can use the standard library function strtoul:

e.g.

char bin[]=&quot;10001&quot;;

unsigned long dec=strtoul(bin,NULL,2);

The other way around, you can create a mask to compare your decimal number against and compare the number and the mask while repeatedly shifting the mask until all the bits have been looked at.

Here is a great link that explains the above with code examples:


HTH,

Russ
bobbitts@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top